Reputation: 391
I tried using distinct as well and it returns duplicates.
$cubes = mysql_query("SELECT distinct * FROM posts ORDER BY RAND() $limit ") or die(mysql_error());
I just want to take my posts table... and return it in a random order without duplicates.
Upvotes: 1
Views: 1984
Reputation: 7315
Are you sure that you want to execute a SELECT DISTINCT * FROM ...
and not just a SELECT DISTINCT column_name FROM ...
?
See the SQL DISTINCT STATEMENT doc for more infos.
Upvotes: 0
Reputation: 116267
Select only the distinct id's you need, e.g.
SELECT distinct id FROM posts ORDER BY RAND() $limit
Distinct
works over 'all' rows you select, so if you (for example) have a unique timestamp field, chances are you'll return every single row.
Upvotes: 4