selecting randon records with a select statement....

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mccommunity
Forum Commoner
Posts: 62
Joined: Mon Oct 07, 2002 8:55 am

selecting randon records with a select statement....

Post by mccommunity »

selecting randon records.... is there a way to do a select statement and select only random items so instead of select * from table limit 10 you could do select random from table limit 10 ? Any help is appreciated. Thanks.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Code: Select all

SELECT * FROM `table` ORDER BY RAND() LIMIT 10
Is the quick and easy way of doing it, can become quite slow on large tables though
Post Reply