文档说REMOVE_REPEATS ( result_set, column, offset, limit ) - removes repeated adjusted rows with the same 'column' value.
,但是当我运行select remove_repeats((select * from rt), gid, 0, 10)
时,记录gid=22
出现了两次,难道不是只出现一次?
mysql> select remove_repeats( (select * from rt),gid,0,10);
+------+------+
| id | gid |
+------+------+
| 1 | 11 |
| 2 | 22 |
| 3 | 33 |
| 4 | 22 |
+------+------+
4 rows in set (0.00 sec)
答案 0 :(得分:0)
REMOVE_REPEATS()仅除去重复的行。如果您通过gid订购子查询,则可以删除第二次出现的gid = 22:
mysql> select remove_repeats( (select * from rt order by gid asc),gid,0,10);
+------+------+
| id | gid |
+------+------+
| 1 | 11 |
| 2 | 22 |
| 3 | 33 |
+------+------+
3 rows in set (0.00 sec)