MySQL query that goes through column in table, returns all unique values once

Discussion in 'PHP' started by pmf123, Jun 25, 2008.

  1. #1
    Looking for the MySQL query that will go through a particular column in a table, and return all unique values only once, and in alphabetical order.

    if a certain value is in 10 rows it will only return that value once.

    ie.

    Test1
    Test5
    Test1
    Test2
    Test1
    Test3
    Test1
    Test2
    Test1
    Test4
    Test1
    Test2
    Test1
    Test2
    Test1

    would return

    Test1
    Test2
    Test3
    Test4
    Test5
     
    pmf123, Jun 25, 2008 IP
  2. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #2
    SELECT word FROM table GROUP BY word ORDER BY word

    - Should be vaguely what you want.
     
    Danltn, Jun 25, 2008 IP
  3. GLD

    GLD Well-Known Member

    Messages:
    307
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    140
    #3
    You could also try:

    SELECT DISTINCT word FROM table
     
    GLD, Jun 26, 2008 IP
  4. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    SELECT DISTINCT word FROM table order by word ASC
     
    wowla_123, Jun 26, 2008 IP