删除 sql 行在其他行中具有相同值的行
delete sql rows that have same value in other rows
我有一个 table 的数据为:
C1 || C2
-----------------
a || 1
b || 1
c || 1
a || 0
b || 0
c || 0
d || 0
我要删除第 4、5、6 行。 C2 = 0 且具有相同 C1 和 C2 = 1 的所有行。建议 ?
delete from your_table
where c2 = 0
and c1 in
(
select c1
from your_table
where c2 in (0,1)
group by c1
having count(distinct c2) = 2
)
我有一个 table 的数据为:
C1 || C2
-----------------
a || 1
b || 1
c || 1
a || 0
b || 0
c || 0
d || 0
我要删除第 4、5、6 行。 C2 = 0 且具有相同 C1 和 C2 = 1 的所有行。建议 ?
delete from your_table
where c2 = 0
and c1 in
(
select c1
from your_table
where c2 in (0,1)
group by c1
having count(distinct c2) = 2
)