delete from tm_terminal_info where exists(
select * from (
select min(id) id,terminal_name from tm_terminal_info group by terminal_name having(count(1)>1)
) as tt where tm_terminal_info.id>tt.id and tm_terminal_info.terminal_name=tt.terminal_name
)
MySql delete语句使用表别名报错:
原因,删除语句时要么不使用表别名,要么在DELETE后面添加上表别名。
格式:delete <alias> from <table> <alias> where <alias>.<field>...
如:
delete a from tm_terminal_info a where exists(
select * from (
select min(id) id,terminal_name from tm_terminal_info group by terminal_name having(count(1)>1)
) as tt where a.id>tt.id and a.terminal_name=tt.terminal_name
)