以下
delete from child N
where parent_id in
(select parent_id , count(*) c
from parent
group by other_attribute having c > 1 )
可以理解地返回
Operand should contain 1 column(s)
你如何解决?
答案 0 :(得分:1)
您无需在子查询中选择计数。只需在HAVING
子句中明确使用计数:
delete from child N
where parent_id in
(
select parent_id
from parent
group by other_attribute
having count(*) > 1
)
答案 1 :(得分:0)
将您的查询修改为
delete from child
where parent_id in (
select parent_id
from parent
group by other_attribute
having count(*) > 1 )
(OR)
将JOIN
查询说成
delete child
from child
join (
select parent_id
from parent
group by other_attribute
having count(*) > 1 ) xxx on child.parent_id = xxx.parent_id;