PHP/MySQL question

Discussion in 'PHP' started by GLD, Apr 7, 2008.

  1. #1
    I have a column (column1) in one of my MySQL tables in which many of the rows have duplicate values for column1.

    Is there any way to create a MySQL query to SELECT DISTINCT and then order by the number of occurences of the value in column1?

    Also, how can I retrieve the number of occurences of certain values in column1? Can this be done without using mysql_num_rows?

    Thank you
     
    GLD, Apr 7, 2008 IP
  2. tamilsoft

    tamilsoft Banned

    Messages:
    1,155
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What about this code:
    SELECT column, count( column ) FROM table GROUP BY column ORDER BY count( column ) DESC
    Code (markup):
     
    tamilsoft, Apr 7, 2008 IP
  3. transient

    transient Member

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    i could be wrong about this, but it seems like you wouldn't need to use count(column) twice.
     
    transient, Apr 7, 2008 IP