DATABASE별 결과 값 RANDOM 으로 나오게 하기

2015. 4. 23. 17:48Database/공통

ORACLE
SELECT * FROM TABLE_NAME SAMPLE (3)
SELECT * FROM (
SELECT * FROM TABLE_NAME ORDER BY DBMS_RANDOM.VALUE
)
WHERE ROWNUM < 3 

MSSQL
SELECT TOP 3 * FROM TABLE_NAME ORDER BY NEWID()

MYSQL
SELECT * FROM TABLE_NAME ORDER BY RAND() LIMIT 0,3