2015-05-08 28 views
0

我已經有數據表:刪除在其他行相同的值SQL行

C1 || C2 
----------------- 
a  || 1 
b  || 1 
c  || 1 
a  || 0 
b  || 0 
c  || 0 
d  || 0 

我已經刪除的行4,5,6。 C2 = 0的所有行,具有相同的C1和C2 = 1。建議?

+2

你應該自己嘗試這個..從一些研究開始..它非常簡單..然後回來,如果遇到問題與您的查詢 – gpullen

回答

0
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 
) 
相關問題