Oracle查询结果集,随机排序
复制代码 代码如下:
select * from table1 order by dbms_random.value();
MySQL随机查询出一条记录:
复制代码 代码如下:
-- 下面的查询语句效率高,不要使用 SELECT * FROM table1 ORDER BY rand() LIMIT 1 来查询 SELECT * FROM table1 WHERE id=(SELECT id FROM table1 ORDER BY rand() LIMIT 1)
查询结果集,随机排序
复制代码 代码如下:
SELECT * FROM table1 ORDER BY rand()
MS SQL Server
复制代码 代码如下:
SELECT *
FROM Northwind Orders
ORDER BY NEWID()
SELECT TOP 10 *
FROM Northwind Orders
ORDER BY NEWID()