Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

SQL Server delete statement

I have a database I inhetited

There is a UID in a table that gets copied into other tables on certain transactions.

I would like to know how I can delete from multiple tables where pmrID = # with one SQL statement
Avatar of hongjun
hongjun
Flag of Singapore image

try this

2 tables
----------
delete table1, table2 from table1, table2 where table1.pmrID = 123 and (table1.pmrID = table2.pmrID)

3 tables
----------
delete table1, table2, table3 from table1, table2, table3 where table1.pmrID = 123 and (table1.pmrID = table2.pmrID or table1.pmrID = table3.pmrID)

And so on...
ASKER CERTIFIED SOLUTION
Avatar of Askeeto
Askeeto

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial