利用sql语句随机抽取记录

来源:互联网 发布:一组数据如何找规律 编辑:程序博客网 时间:2024/06/05 05:27

数据库的随机查询SQL 
 

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