How to return randomly multiple rows in postgresql?

Member

by ryleigh , in category: MySQL , 10 months ago

How to return randomly multiple rows in postgresql?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raven_corwin , 10 months ago

@ryleigh 

You can return randomly multiple rows in PostgreSQL using the following query:

1
SELECT * FROM your_table ORDER BY RANDOM() LIMIT n;


Replace your_table with the name of the table you want to select rows from, and n with the number of rows you want to return randomly. This query will order the rows randomly using the RANDOM() function and limit the result set to n rows.

Related Threads:

How to add values in single column of multiple rows in postgresql
How to return similar xml elements as rows in oracle?
How to return 0 instead of null in postgresql?
How to update multiple rows in laravel at once?
How to insert multiple rows in laravel?
How to update multiple rows in laravel?