I am trying to delete inserted data from table1 where a certain column from table2 (sname) is null. I am trying to achieve this through a left outer join but don't understand yet the fundamentals of it.
table1 | anum pnum
===========
001 001
002 001
003 002
004 002
table2 | anum sname
============
001 'cooking'
001 'cleaning'
002 'teaching'
003 NULL
Any tips are highly appreciated.
To delete the rows in table1 where the corresponding value of sname in table2 is null, use this query:
DELETE table1
FROM table1
JOIN table2
ON table2.anum = table1.anum
WHERE table2.sname IS NULL;
DELETE
FROM table1
INNER JOIN table2
ON table1.anum = table2.anum
WHERE table2.sname IS NULL;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.