如果一个表是这样的:
id | complains | zipcode
--------------------------
1 | drinking | 10000
2 | drinking | 10000
3 | wasting | 10000
4 | wasting | 10000
5 | wasting | 10000
6 | wasting | 10011
7 | wasting | 10011
我只想得到:
---------------
drinking 10000
wasting 10000
wasting 10011
---------------
我应该如何编写 SQL 查询?我是这样写的,但是在mySQL中不能同时执行update和select。
delete from table where id not in (select max(id) from table group by complains, zipcode)