Hello 'alternate_db', >>> Now, what is the best way to pull out 20 random rows from my questions >>> table?
>> $query = "SELECT q_id, question FROM questions ORDER BY RAND() LIMIT >> 0, 20"; >> This will give you 20 random records. >I'm having one problem with that statement: I'm getting duplicate rows >being selected, even after adding DISTINCT to my query, even when the >limit is below the total number of rows. That should not be possible. I just tested it on a table selecting only one less than the total number of records in the table and had not a single duplicate. Make sure you are doing ONE query only and not repeating this query n times as of course then there will be duplicates. Put an 'print($Query);' line in your script to dump the query you actually sent to the database to the screen, and verify its action. When still having trouble, copy the query from the browser screen and post it here. This thing may happen if your query contains a join generating duplicate records (for instance because you select a limited number of fields and not all fields). Now the rand() has a good chenca of picking two identical result rows. Marc ___________________________________ Webmail TOP Internet www.top.com.br Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/php-list/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
