RE: ORDER BY RAND() gives me duplicate rows sometimes

2006-11-10 Thread Jerry Schwartz
.674.8796 / FAX: 860.674.8341 > -Original Message- > From: Christian Hammers [mailto:[EMAIL PROTECTED] > Sent: Friday, November 10, 2006 2:57 AM > To: Daevid Vincent > Cc: mysql@lists.mysql.com > Subject: Re: ORDER BY RAND() gives me duplicate rows sometimes > > > >

Re: ORDER BY RAND() gives me duplicate rows sometimes

2006-11-10 Thread uYe
Add DISTINCT(primary_key) in your query? Regards Willy -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: ORDER BY RAND() gives me duplicate rows sometimes

2006-11-09 Thread Christian Hammers
On 2006-11-09 Daevid Vincent wrote: > 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 t

ORDER BY RAND() gives me duplicate rows sometimes

2006-11-09 Thread Daevid Vincent
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? -- M