I have tables A and B and I want to delete any value in table A that is also in table B.
Table A has [1, 2, 3, 4, 5, 6] and B has [2, 4, 5].
You actually want to delete those values, or you just wan't to do a Join where only values that exist in both tables are selected?
The syntax will be realtively similare either way.
delete B values from A
I am assuming that your data is a bit more complex then the sample that you have provided.
The query would look something like:
DELETE
FROM [Table A]
WHERE Some_ID_Column IN (Select Some_ID_Column FROM [Table B])
I would recommend that you run a select statement first to insure you're syntax actually properly selects the rows you are actually wanting to delete.
Select *
FROM [Table A]
WHERE Some_ID_Column IN (Select Some_ID_Column FROM [Table B])
The ID column doesn't need to actually be an ID column, but some identifying expression that selects single rows from Table A.
1 Like
It works, thank you!