View Single Post
Old 06-18-2010, 04:05 PM  
amphibient
Registered User
 
Join Date: Jul 2003
Location: Florida
Posts: 21
there are a few things you can do. If the table is small - i see you only want 44 records - if it's no larger than 100 or so records (that's an arbitrary number) you could just pull all of the records and pick them randomly using your programming language of choice (PHP?).

if the table is huge, you could do something like

SELECT id, col1, col2, ... , colN FROM tab WHERE id IN (SELECT id FROM tab WHERE conditions ORDER BY RAND() LIMIT m)

(taken from the dev.mysql.com/doc/refman/5.0/en/order-by-optimization.html comments)

How random do you want it to be?
amphibient is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook