Home Databases mySql How to get random rows when querying a database table using mySql?
 
 
 

How to get random rows when querying a database table using mySql?

PDF Print E-mail
Question: How to get random rows when querying a database table using mySql? For example if you have a table with 100 rows in it and you need to get 3 random rows then this could come in handy.

 

Answer:

 

 
 
SELECT * FROM ads ORDER BY RAND() LIMIT 3
 
 


We've used the RAND() function to return random table rows
+/-
+/- Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):s
:!::?::idea::arrow:
Security Please input the anti-spam code that you can read in the image.
 

Go Daddy $7.49 .com Sale!