I have tow tables
tests_sub ,tests_sub_sub
and tests_sub.id = tests_sub_sub.id
so i want to delete data from both tables with one
sql query
I used the following inner join
DELETE tests_sub, tests_sub_sub FROM tests_sub
INNER JOIN tests_sub_sub ON tests_sub_sub.id = tests_sub.id
WHERE tests_sub.id = 10
the query works ok only if both tables have entries for the tests_sub.id... ( if tests_sub_sub has no entry for test_sub.id = 10 ... although the table tests_sub has entries for that id no rows are affected ... please suggest some tips....
use LEFT JOIN
.
DELETE tests_sub, tests_sub_sub
FROM tests_sub
LEFT JOIN tests_sub_sub
ON tests_sub_sub.id = tests_sub.id
WHERE tests_sub.id = 10
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.