此查询将删除所有行,而我只想删除measureid
两个表中匹配的行,如下所示:
delete from temp1
where exists (select t1.*
from temp1 t1, temp2 t2
where t2.measureid = t1.measureid)
我必须改变什么?
此查询将删除所有行,而我只想删除measureid
两个表中匹配的行,如下所示:
delete from temp1
where exists (select t1.*
from temp1 t1, temp2 t2
where t2.measureid = t1.measureid)
我必须改变什么?
我想你不想用exists
我想你想用in
delete from temp1 where measureid in
(select t1.measureid from temp1 t1, temp2 t2 where t2.measureid = t1.measureid);
或者更好
delete from temp1 where measureid in
(select measureid from temp2);
那是因为
select t1.* from temp1 t1, temp2 t2 where t2.measureid = t1.measureid
总是返回行。你可能想要的是
delete from temp1 t1 where exists (select t2.* from temp2 t2 where t2.measureid = t1.measureid)