WEB开发网
开发学院数据库MySQL mysql中如何随机提取数据库记录 阅读

mysql中如何随机提取数据库记录

 2009-07-03 07:27:00 来源:WEB开发网   
核心提示:帮朋友改个asp的相关产品显示要用到随机读取当前类别的前10个产品,Google了下收藏的mysql中随机提取数据库记录 view plaincopy to clipboardprint?select * from tablename order by rand() limit 10select * from tabl

帮朋友改个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字段名

Tags:mysql 如何 随机

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接