- mysql> select * from test1;
- +------+------+
- | id | c_id |
- +------+------+
- | 1 | 0013 |
- | 2 | 0014 |
- | 3 | 0013 |
- | 4 | 0013 |
- +------+------+
- 4 rows in set (0.06 sec)
- mysql> delete t from test1 t left join
- -> (select c_id,min(id) as min_id from test1 group by c_id) t1
- -> on t.id=t1.min_id
- -> where t1.min_id is null;
- Query OK, 2 rows affected (0.06 sec)
- mysql> select * from test1;
- +------+------+
- | id | c_id |
- +------+------+
- | 1 | 0013 |
- | 2 | 0014 |
- +------+------+
- 2 rows in set (0.00 sec)
- mysql>