删除多个表SQL

时间:2016-02-11 23:46:25

标签: sql sql-delete

我试图删除多个数据/行表,但不允许我,因为错误始于 - > a,b,c,d,e< - 表示"无效列"并没有找到我的错误......在这里我的代码:

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

我试过很多选择:

DELETE FROM 
DELETE * FROM
DELETE a.*,b.*,c.*,d.*,e.* 

3 个答案:

答案 0 :(得分:1)

 DROP TABLE table1,table2,table3 ...

答案 1 :(得分:0)

DELETE t1, t2 
FROM t1 
INNER JOIN t2 
INNER JOIN t3
WHERE t1.id = t2.id AND t2.id = t3.id;

答案 2 :(得分:0)

从DELETE子句中删除列(*):

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

这将删除每个表ProvidersUsersProvidersUsersProviderSubscriptionsSubscriptions中的匹配行。