I have the following problem with two tables:
table1 has
- uid
- name
table2 has
- id
- name
I want to write a sql script that deletes all rows from table1 which don't meet the condition
table1.uid = table2.id
I have the following problem with two tables:
table1 has
table2 has
I want to write a sql script that deletes all rows from table1 which don't meet the condition
table1.uid = table2.id
delete from table1 t1
where not exists (select 1 from table2 where id = t1.uid)
或者
delete from table1
where uid not in (select id from table2)
DELETE FROM table1
WHERE NOT EXISTS
( select table2.name
from table2
where table1.uid = table2.id);