Skip to content
Advertisement

Difference between delete statements

vs.

Advertisement

Answer

The logical conditions of the two statements are different.

The first statement will delete any row in TableA if both it’s Field1 and Field2 correspond to the equivalent columns of a row in TableB.

The second statement will delete any row in TableA if the value of Field1 exists in Field1 of TableB, and the value of Field2 exists in Field2 of TableB – but that doesn’t have to be in the same row.

It’s easy to see the difference if you change the delete to select.

Here’s an example. First, create and populate sample tables (Please save us this step in your future questions):

The statements (translated to select statements):

Results:

And you can see a live demo on DB<>Fiddle

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement