MySQL语句如何从数据库表中查询随机数据记录
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
SELECT * FROM phpcms_video where catid=17 order by rand()
获取到的随机结果如下图所示:
![图片[1]-MySQL语句如何从数据库表中查询随机数据记录-2345资源网 - 精品建站资源与技术分享平台](https://i1.nzw6.com/2022/11/20221124061258969.jpg)
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END













暂无评论内容