random result no duplicates

Discussion in 'MySQL' started by webboy, Aug 31, 2008.

  1. #1
    Hi all I have mysql query that I wish to display a random result of 60 rows without any duplicates


    E.g. the rows are A B B C
    I wish to see a result of C A B

    Do use concatenate here if so where

    SELECT DISTINCT * FROM TABLE WHERE X <> 'null' AND ORDER BY RAND() LIMIT 60
     
    webboy, Aug 31, 2008 IP
  2. webboy

    webboy Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2

    but i seen to get duplicate rows when processing this query
    i have looked at the data it seem to be idenetical on the output
     
    webboy, Sep 1, 2008 IP
  3. CreativeClans

    CreativeClans Peon

    Messages:
    128
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The query should give an error:

    SELECT DISTINCT * FROM TABLE WHERE X <> 'null' AND ORDER BY RAND() LIMIT 60

    Get rid of that 'AND' and see what happens.
    Anyway, doing a DISTINCT on all fields in the table, means you'll only get rid of rows that are identical in all field values. If you want to eliminate duplicate values of one or some of the fields present in the table, you'll have to name them explicitly in the SELECT (ie. SELECT DISTINCT field1, field2 FROM...)
     
    CreativeClans, Sep 2, 2008 IP