0

the document said REMOVE_REPEATS ( result_set, column, offset, limit ) - removes repeated adjusted rows with the same 'column' value. but when I run select remove_repeats((select * from rt), gid, 0, 10), The record gid=22 appeared twice.Shouldn't it appear only once?

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)

1 Answer 1

0

REMOVE_REPEATS() removes only repeated rows going one by another. In your case you can remove the 2nd occurrence of gid=22 if you order the sub-query by gid:

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.