Sql server,Oracle,MySQL随机查询记录
2006-11-20 12:42
作者:罗代均 ldj_work#126.com,转载请保持完整性
1. Oracle,随机查询20条
select * from
(
select * from 表名
order by dbms_random.value
)
where rownum <= 20;
2.MS SQL Server,随机查询20条
select top 20 * from 表名order by newid()
3.My SQL:,随机查询20条
select * from 表名 order by rand() limit 20
本文介绍了在Oracle、MSSQLServer及MySQL三种数据库中实现随机查询记录的方法,包括使用不同的函数来确保每次查询结果的随机性,并针对每种数据库提供了具体的SQL语句。
1725

被折叠的 条评论
为什么被折叠?



