首页 > 开发 > 综合 > 正文

读取随机记录的例子 SQL语句

2024-07-21 02:44:38
字体:
来源:转载
供稿:网友

帮朋友改个asp的相关产品显示要用到随机读取当前类别的前10个产品,Google了下收藏的

MySQL中随机提取数据库记录
-------------------------------------------------------------------------------- view plaincopy to clipboardPRint?
select * from tablename order by rand() limit 10 

select * from tablename order by rand() limit 10sqlserver中随机提取数据库记录
-------------------------------------------------------------------------------- view plaincopy to clipboardprint?
select top 10 * from tablename order by NEWID() 

select top 10 * from tablename order by NEWID()access中随机提取数据库记录
-------------------------------------------------------------------------------- view plaincopy to clipboardprint?
SELECT top 10 * FROM tablename ORDER BY Rnd(FId) 

SELECT top 10 * FROM tablename ORDER BY Rnd(FId)FId:为你当前表的ID字段名


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表