Random Select

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

Random Select

Post by mzfp2 »

Hi

is it possible to select say 5 random records from a database (MYSQL) which satisfy a certain criteria, eg SELECT RANDOM(5) from useers where user='alive'?

or would it need some sort of PHP intervention?

Thanks
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

Yes

SELECT * FROM `table` ORDER BY RAND() LIMIT 5


PS: Request move to databases.
mzfp2
Forum Contributor
Posts: 137
Joined: Mon Nov 11, 2002 9:44 am
Location: UK
Contact:

Post by mzfp2 »

great thanks! lightening response and the solution too .. thanks a billion man
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

I hava nothing else to do :)
Post Reply