我想从表中删除仅出现一次的行。
我已经尝试过了,但这给了我错误。
delete from trans where nol in (select nol from trans T1 group by T1.nol having count(*) = 1)
最佳答案
在MySQL中,您不能修改SELECT部分中使用的同一表。
要解决此问题,您需要将子查询包装到表别名中。
查询样例:
delete from trans
where nol in (SELECT nol FROM
(select nol from trans T1 group by T1.nol having count(*) = 1) t)