faqts : Computers : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

183 of 199 people (92%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

how can i select random rows from a table?

Nov 22nd, 2008 02:53
haytham ali, dman, ditoiu cristian, stuart gilbert, Ryan Parr, Arman Galstyan, http://www.msryat.org


SELECT * FROM table_name ORDER BY RAND();
Found at http://www.mysql.com/doc/M/a/Mathematical_functions.html
use:
SELECT * FROM table_name ORDER BY RAND() limit 1;
if you only want one result not all of them.
http://6rb.com
http://fr7.com
http://dir.msryat.org
http://6ef.com
http://forums.msryat.org
http://www.arabcar.com