我需要从一个表中删除数据,但对WHERE子句使用另一个表.因此,我只想删除在输出中获得的值,而不是不同表中的任何值.
我要从中删除数据的表有两行:ot_id和分类id
select
t0.*
from ot_classification t0
left join
ot t1
on t0.ot_id=t1.id
where t1.ct = '22GC'
and t0.classification_id not in '157101'
我认为我应该做的是:
delete t0.ot,
t0.classification_id
from ot_classification t0
left join
ot t1
on t0.ot_id=t1.id
where t1.ct = '22GC'
and t0.classification_id not in '157101'
恐怕这也会删除t1.id,这不是我想要的.我怎么才能避免这种情况?