Jordan Brough Stuff I found online.

 Subscribe

 Twitter

Posted
January 13, 2009
12:59 pm

In
Tech

Selecting a Random Row From a SQL Database

There are plenty of ways to select random records from a database, here are a few simple statements that don’t require any advanced logic.

Select a random row with MySQL:
[snippet=11412]
Select a random row with PostgreSQL:
[snippet=11414]
Select a random row with Microsoft SQL Server:
[snippet=11415]
Select a random row with IBM DB2
[snippet=11416]
Select a random record with Oracle:
[snippet=11417]
Have you got other examples or variations?  Please add them in the comments.

blog comments powered by Disqus