Friday, October 25, 2013

MySQL select random rows

Below is the example of MySQL statement   to select 4 random rows form table cesei_members using ORDER BY RAND() LIMIT 4:

SELECT * FROM  cesei_members  ORDER BY RAND() LIMIT 4;

I use it to randomly pick up 4 committee members for each module.

No comments:

Post a Comment