|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Delete from Table A values not found in Table B
I find a number of records with this query:
SELECT * FROM TableA a Where Not Exists (Select * TableB b Where b.ColumnB1 = a.ColumnA1) I'd like to delete the records I've found from TableA like this: Delete FROM TableA a Where Not Exists (Select * TableB b Where b.ColumnB1 = a.ColumnA1) But alas, the syntax error near "a" Thanks for any help! -robot |
|
#2
|
|||
|
|||
|
Code:
Delete FROM TableA Where Not Exists (Select * from TableB b Where b.ColumnB1 = TableA.ColumnA1) |
|
#3
|
|||
|
|||
|
DELETE FROM tableA
WHERE columnA NOT IN (SELECT columnB FROM tableB) might actually be faster |
|
#4
|
|||
|
|||
|
Since the queries are not equivivalent I don't see the purpose of comparing them performancewise.
|
|
#5
|
|||
|
|||
|
Hmm. I would think that they are equivalent. Why do you think the NOT IN does something different then the NOT EXISTS?
|
|
#6
|
|||
|
|||
|
The queries will behave differently with regard to nulls.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Delete from Table A values not found in Table B |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|