Pages

Saturday, April 16, 2011

Selecting Random Records From Database.....


Select random rows in MySQL

A dL creations Code....
Following query will fetch 10 random rows from MySQL.
1
2
3
SELECT column FROM table
ORDER BY RAND()
LIMIT 10

Select random rows in Oracle

A dL creations Code....
1
2
3
4
SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum <= 10

Select random rows in PostgreSQL


1
2
3
SELECT column FROM table
ORDER BY RANDOM()
LIMIT 10

Select random rows in Microsoft SQL Server

1
2
SELECT TOP 10 column FROM table
ORDER BY NEWID()
A dL creations Code....

No comments:

Post a Comment