This is a discussion on ORDER BY RAND() gives me duplicate rows sometimes within the MySQL General forum forums, part of the MySQL category; --> I am using this query to pull three random comments from a table: "SELECT *, DATE_FORMAT(created_on, '%b %D') as ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I am using this query to pull three random comments from a table: "SELECT *, DATE_FORMAT(created_on, '%b %D') as date_format FROM comments ORDER BY RAND() LIMIT 3"; The problem is that sometimes, I get two of the same comment. How can I refine this query to give me 3 unique/distinct ones? |
| Thread Tools | |
| Display Modes | |
|
|