当前位置:网站首页>在各類數據庫中隨機查詢n條數據
在各類數據庫中隨機查詢n條數據
2022-07-22 18:55:00 【瓦坎達forever】
使用場景 :
樓主用在B/S客戶端中隨機顯示一些推薦消息給用戶的界面當中MySQL
數據庫查詢隨機數據:
//這裏的8是指你想要查幾條隨機數據
SELECT * FROM Table_Name ORDER BY RAND() LIMIT 8;
SQL Server
數據庫查詢隨機數據:
//一樣道理,將8替換為你想要查詢的信息條數
SELECT TOP 8 * FROM Table_Name ORDER BY NEWID();
Oracle
:
//樓主用的是Oracle去查詢隨機數據
SELECT * FROM (SELECT * FROM Table_Name ORDER BY DBMS_RANDOM.RANDOM()) WHERE Rownum <= 8;
边栏推荐
猜你喜欢
Flink学习笔记(五)DataStream API
04. interface aggregation principle
Wechat official account web page authorization ----- redirect_ The URI domain name is inconsistent with the background configuration, and the error code is 10003
Thymeleaf中一个页面怎么嵌套另一个页面,关于页面嵌套,标签告诉你应该知道的
LeetCode: 184. 部门工资最高的员工
STM32+ESP8266+MQTT协议连接OneNet物联网平台
1.常量中有换行符Qt5-》vs的解决方案;2.同一份代码Qt和vs共同编译的问题和解决方案
1.Qt之打包发布程序 (NSIS);
Caching-sha2-password problem occurred when connecting mysql8.0
微信扫网址的二维码,却只显示链接地址,无法跳转到网页的解决办法
随机推荐
数据存储分区--范围分区,哈希分区,列表分区,性能调优必不可缺少的部分
Wechat official account web page authorization ----- redirect_ The URI domain name is inconsistent with the background configuration, and the error code is 10003
01. Open closed principle
PTA 习题8-8 判断回文字符串
BigDecimal中除法divide()方法的详细解析,带你走进源码的world
Qt | 模态对话框和非模态对话框 QDialog
Solve the problem that the target bytecode version number of IntelliJ cannot be maintained
消息中间件
LeetCode 654. 最大二叉树
国内 Ngrok 实现内网穿透
LeetCode:196. 删除重复的电子邮箱
bjyx
ps: 如何调出辅助线
PAT乙级1020月饼(注意测点)
Summary 20220214
递归求简单交错幂级数的部分和 (15分)
Summary of various technical data -mysql
JSON序列化对象时,如何返回有空值的带属性名称json字符串?
ECSHOP need to modify the folder and file of permission? The error directory cannot be written
How PHP prevents CSRF attacks