SQL SELECT RANDOM() function is used to select random rows from the result set. This is useful to select random question in online question.
There are many different ways to select random record or row from a database table. Each database has it’s own syntax to achieve the same.
If you want select a random record in MY SQL:
SELECT column_name FROM table_name ORDER BY RAND ( ) LIMIT 1;
If you want to select a random record in Microsoft SQL Server:
SELECT TOP 1 column_name FROM table_name ORDER BY NEW ID();
If you want to select a random record in Oracle database:
SELECT column_name FROM (SELECT column_name FROM table_name ORDER BY dbms_random.value) WHERE rownum =1;
If you want to select a random record in PostgreSQL:
SELECT column_name FROM table_name ORDER BY RAND() LIMIT 1;