Categories
mysql postgresql

Postgresql/Mysql : Selecting random rows

Let say we have a table containing famous quote and we want to show a random quote. How do that in postgresql ? Try this.

Select * from quote order by random() limit 1;

for Mysql use rand instead.

Select * from quote order by rand() limit 1;

 

Leave a Reply

Your email address will not be published. Required fields are marked *