三种数据库随机查询语句写法


  本文标签:随机查询语句

  随机查询是我们经常能够碰到的问题,下面为您介绍了三种数据库中随机查询语句的写法,供您参考,希望对您学习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