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
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
相关文章推荐
- 用命令创建MySQL数据库(de1)
- Oracle学习(十一)之 PL/SQL
- Redis AOF文件
- SQL命令行修改数据库
- Oracle学习(十)之 过程
- Oracle 查看锁和释放锁
- Redis RDB文件
- MongoDB 更新的简单使用
- oracle pl/sql之sql中的%type
- [置顶] [实验-视频过程]oracle控制文件增加减少
- mysql 和oracle的函数比较
- 【MySQL】【leetcode】 Delete Duplicate Emails解题报告
- MySql--查询某字段相同数据的条数据
- iOS学习之sqlite的创建数据库,表,插入查看数据
- mysql 数据表中查找重复记录
- sysbench测试mysql与postgresql
- PostgreSQL数据库表名大小写问题
- oracle中的事务
- redis sentinel 高可用集群
- 查看MySQL的当前存储引擎