19 March 2014

SQL SELECT RANDOM ROW

This sample is query to randomly select a row of data on a MySQL table:

SELECT column FROM table
ORDER BY RAND()
LIMIT 1

This sample is query to randomly select a row of data on a SQL Server table:

SELECT TOP 1 column FROM table
ORDER BY NEWID()

Click here if you like this article.


0 comments: