Wednesday, March 7, 2012

how to delete from Table A based on Table B

lets say i have 100 employees on Table A and I have 10 employees on Table B. I want to delete all the employees in Table A that are in Table B.
Delete From TableA Where EmpNum = (Select EmpNum From TableB)
The above SQL wont work but i am looking for something similar. any ideas?You should use IN as your subquery is returning multiple records.
Delete From TableA Where EmpNum IN (Select EmpNum From TableB)

No comments:

Post a Comment