SQL -Structured Query Language - Sql Order By - Random Tutorial
To retrieve the record in random order from the existing created table. Then we can use an ' ORDER BY ' Clause with RAND() Function.
Syntax-
The basic syntax of the ORDER BY statement with RAND() or RANDOM() function is given below –
SELECT * FROM table_name ORDER BY RAND();/*on error use RANDOM()*/
For example-
SELECT * FROM employees ORDER BY RAND(); /*on error use RANDOM() */
Here it will retrieve random records from the employees' table.