Click to See Complete Forum and Search --> : randomly selecting a couple of rows...?


gilly914
January 31st, 2006, 03:33 AM
Hey...

How can I randomly select 4 different rows from a MySQL database using SQL???

Is this even possible in SQL?

Thanks, gilly914

hspc
January 31st, 2006, 04:00 AM
you can find some ideas in :
http://dev.mysql.com/doc/refman/5.0/en/select.html

exterminator
February 1st, 2006, 02:32 AM
How can I randomly select 4 different rows from a MySQL database using SQL??? Is this even possible in SQL?...Yup! It is very much possible... Use the NEWID() function. Have a look at this thread - How to get random row from table? (http://www.codeguru.com/forum/showpost.php?p=1261879&postcount=3) Hope this helps. Regards.

hspc
February 2nd, 2006, 03:16 AM
Use the NEWID() function.

He's using MySQL,,NEWID() function is available in MS SQL Server.

exterminator
February 2nd, 2006, 04:16 AM
He's using MySQL,,NEWID() function is available in MS SQL Server.Aahh.. you are right! I overlooked that - I saw MySQL as MS SQL... even when I saw it as MySQL .. it sounded MS SQL in my head. So sorry for that. Regards.