Browse Search  
Home :MySQL :

how can i select random rows from a table?
Category : MySQL
 
 
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.
 
 
This article has been viewed 856 times.



ASPWebHosting.com.au Copyright © 2004-2005 | All Rights Reserved |

All trademarks are property of their legal owners.