djmonkey1
08-08-2006, 11:51 AM
Hello-
Here is my scenario: I want to be able to delete rows from three different tables, A, B, and C, using the the same two keys (1 and 2) for each one. The catch is that data might not exist in Table B, and even if it does, it might not exist in Table C (the query wouldn't exist if there was no matching row in Table A).
After much wailing and gnashing of teeth I came up with a query in this format:
DELETE A, B, C FROM A aa, B bb, C cc
WHERE aa.1 = '1'
AND bb.1 = '1'
AND cc.1 = '1'
AND aa.2 = '2'
AND bb.2 = '2'
AND cc.2 = '2'
The works great if matching data exists in all three tables, but not at all when matching data doesn't exist in B and/or C.
So is there a different syntax I can use or should I stick with three queries?
Here is my scenario: I want to be able to delete rows from three different tables, A, B, and C, using the the same two keys (1 and 2) for each one. The catch is that data might not exist in Table B, and even if it does, it might not exist in Table C (the query wouldn't exist if there was no matching row in Table A).
After much wailing and gnashing of teeth I came up with a query in this format:
DELETE A, B, C FROM A aa, B bb, C cc
WHERE aa.1 = '1'
AND bb.1 = '1'
AND cc.1 = '1'
AND aa.2 = '2'
AND bb.2 = '2'
AND cc.2 = '2'
The works great if matching data exists in all three tables, but not at all when matching data doesn't exist in B and/or C.
So is there a different syntax I can use or should I stick with three queries?