简体   繁体   中英

Delete multiple tables SQL

I have tried to delete multiple data/rows tables, but does not allow me as the error starts at -> a, b, c, d, e <- that says "invalid column" and not find what is my mistake ... here my code:

DELETE a.*,b.*,c.*,d.*,e.* FROM [CatMngSys].[Providers] a
INNER JOIN [Security].[UsersProviders] b
ON a.Id = b.ProviderId
INNER JOIN [Security].[Users] c
ON b.UserId = c.Id
INNER JOIN [CatMngSys].[ProviderSubscriptions] d
ON d.ProviderId = a.Id
INNER JOIN [CatMngSys].[Subscriptions] e
ON e.Id = d.SubscriptionId
WHERE a.id = @Id

and i have tried for many options:

DELETE FROM 
DELETE * FROM
DELETE a.*,b.*,c.*,d.*,e.* 
 DROP TABLE table1,table2,table3 ...
DELETE t1, t2 
FROM t1 
INNER JOIN t2 
INNER JOIN t3
WHERE t1.id = t2.id AND t2.id = t3.id;

Remove the columns (*) from the DELETE clause:

DELETE a, b, c, d, e
FROM [CatMngSys].[Providers] a
INNER JOIN [Security].[UsersProviders] b ON a.Id = b.ProviderId
INNER JOIN [Security].[Users] c ON b.UserId = c.Id
INNER JOIN [CatMngSys].[ProviderSubscriptions] d ON d.ProviderId = a.Id
INNER JOIN [CatMngSys].[Subscriptions] e ON e.Id = d.SubscriptionId
WHERE a.id = @Id

This'll delete matching rows in each of tables Providers , UsersProviders , Users , ProviderSubscriptions and Subscriptions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM