mardi 15 septembre 2015

PHP MySQL select random rows where a row is different

What Im Trying to achieve is selecting multiple rows randomly where a certain column is different from the last for example

SELECT * FROM mytable WHERE `column_for_duplicate_values` != '$thelastkey' ORDER BY RAND() LIMIT 10

the column for multiple values would hold for example:

1 , 1 , 1 , 1 , 2, 5 , 6, 6 , 6 , 6 , 6 , 11 , 11 ,  11 , 19

and I want to select 1 from each. So I would get

1 , 2 , 5 , 6 , 11 , 19




Aucun commentaire:

Enregistrer un commentaire