随机抽样 如何实现随机每隔5条就提取出一条数据! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主是不是想要这种?mysql> select * from table1;+----+------+| id | c1 |+----+------+| 1 | A1 || 2 | A2 || 3 | A3 || 4 | A4 || 5 | A5 || 6 | A6 || 7 | A7 || 8 | A8 || 9 | A9 || 10 | A10 || 11 | A11 || 12 | A12 || 13 | A13 || 14 | A14 || 15 | A15 || 16 | A16 || 17 | A17 || 18 | A18 || 19 | A19 || 20 | A20 || 21 | A21 || 22 | A22 || 23 | A23 || 24 | A24 || 25 | A25 || 26 | A26 || 27 | A27 || 28 | A28 || 29 | A29 || 30 | A30 || 31 | A31 |+----+------+31 rows in set (0.00 sec)mysql> select table1.* -> from table1,(select 1+FLOOR(rand()*5)+((id-1) div 5)*5 as tid -> from table1 -> where id%5=0) t -> where table1.id=t.tid;+----+------+| id | c1 |+----+------+| 3 | A3 || 6 | A6 || 13 | A13 || 17 | A17 || 25 | A25 || 29 | A29 |+----+------+6 rows in set (0.00 sec)mysql> select a.* from lsb1 a inner join(select *,ceiling(id/5) as newid,ceiling(rand()),floor(id-rand()*5+1) as newid1from lsb1 where id mod 5=0) bon a.id=b.newid1 求助:优化my.cnf配置 如何判断数据中是否存在空值? MySQL 日期格式转换 java连接MySQL问题 关于权限问题 mysql中文查询得不到结果 触发器中STRCMP函数问题 请教怎么合并视图 LIKE的使用问题 [求助]多条件判断怎么写? ERROR 1172 (42000): Result consisted of more than one row? MYSQL问题请教
+----+------+
| id | c1 |
+----+------+
| 1 | A1 |
| 2 | A2 |
| 3 | A3 |
| 4 | A4 |
| 5 | A5 |
| 6 | A6 |
| 7 | A7 |
| 8 | A8 |
| 9 | A9 |
| 10 | A10 |
| 11 | A11 |
| 12 | A12 |
| 13 | A13 |
| 14 | A14 |
| 15 | A15 |
| 16 | A16 |
| 17 | A17 |
| 18 | A18 |
| 19 | A19 |
| 20 | A20 |
| 21 | A21 |
| 22 | A22 |
| 23 | A23 |
| 24 | A24 |
| 25 | A25 |
| 26 | A26 |
| 27 | A27 |
| 28 | A28 |
| 29 | A29 |
| 30 | A30 |
| 31 | A31 |
+----+------+
31 rows in set (0.00 sec)mysql> select table1.*
-> from table1,(select 1+FLOOR(rand()*5)+((id-1) div 5)*5 as tid
-> from table1
-> where id%5=0) t
-> where table1.id=t.tid;
+----+------+
| id | c1 |
+----+------+
| 3 | A3 |
| 6 | A6 |
| 13 | A13 |
| 17 | A17 |
| 25 | A25 |
| 29 | A29 |
+----+------+
6 rows in set (0.00 sec)mysql>
(select *,ceiling(id/5) as newid,
ceiling(rand()),floor(id-rand()*5+1)
as newid1
from lsb1 where id mod 5=0) b
on a.id=b.newid1