您的位置:首页 > 数据库

sql随机抽取数据

2015-10-20 15:43 225 查看
mysql: select * from tablename order by rand() limit 10

sqlserver: select top 10 * from tablename order by NEWID()

select ts_name from 表名 as t1 JOIN (RAND()*((select MAX(t_id) FROM 表名)-(select MIN(t_id) from 表名))+(select MIN(t_id) from 表名) as id) as t2
where t1.t_id
>=t2.t_id ORDER BY t1.id LIMIT 1

来自:http://bbs.blueidea.com/thread-359132-1-1.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: