sql语句随机提取N条记录
Sql server用法:
SELECT TOP N * FROM TABLENAME ORDER BY NEWID()
SELECT TOP N * FROM TABLENAME ORDER BY NEWID()
N:是随机的条数;
TABLENAME:是用的表名
Access:
SELECT TOP N * FROM TABBLENAME ORDER BY RND(ID)
Rnd(id) 其中的id是自动编号字段,可以利用其他任何数值来完成
比如用姓名字段(UserName)
SELECT top 10 * FROM 表 ORDER BY Rnd(len(UserName))
MySql:
SELECT * FROM TABLENAME ORDER BY RAND() LIMIT N