Contact iFingers

Finger Tips - a fistful of handy web notes

Tuesday, June 13, 2006

MySQL Random Selection

So, you want to find a random result from your MySQL database? Yeah, me too. I have struggled for ages, using fancy queries. If I was clever I would have used this MySQL statement:

SELECT * FROM mytable WHERE myfield = 'something' ORDER BY RAND() LIMIT 1

0 Comments:

Post a Comment

<< Home