MySQL语句如何从数据库表中查询随机数据记录

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()

 

获取到的随机结果如下图所示:

 

 

 

MySQL语句如何从数据库表中查询随机数据记录

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/114929.html<

(0)
运维的头像运维
上一篇2025-02-17 23:33
下一篇 2025-02-17 23:34

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注