Grow your CSS skills. Land your dream job.

[Solved] PHP MySQL Query

  • # April 3, 2010 at 4:47 pm

    Hi, I need a query that searches my database in a single row called ‘type’ and then extracts all of the types of type.
    I can get it to extract all of the values but values in ‘type’ is used for mote than one row so where i end up echoing out

    Code:
    typeOne
    typeOne
    typeTwo
    typeThree
    typeOne
    typeTwo
    typeOne
    typeOne
    typeTwo
    typeTwo
    typeThree

    I want to only echo out

    Code:
    typeOne
    typeTwo
    typeThree

    Hope this makes sense and thanks in advance.

    # April 3, 2010 at 5:53 pm

    Add

    Code:
    GROUP BY type

    to your query

    # April 4, 2010 at 6:58 am

    Hi, will that piece of code remove the duplicate entries or just order them so they are all together?

    Many Thanks

    # April 4, 2010 at 7:33 am

    Well, it groups them together so you would only have

    Code:
    Group One
    Group Two
    Group Three

    But then looking at what you want, it may be better to use SELECT DISTINCT(type)

    # April 4, 2010 at 6:59 pm

    Thanks, DISTINCT was exactly what was needed.

    Many Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".