0

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.* 
1
  • 1
    Which RDBMS is this for? Please add a tag to specify whether you're using mysql, postgresql, sql-server, oracle or db2 - or something else entirely. Commented Feb 12, 2016 at 5:55

3 Answers 3

1
 DROP TABLE table1,table2,table3 ...
Sign up to request clarification or add additional context in comments.

2 Comments

hmmm i don't want to delete the tables... only specific rows of every tables
joining a-b-c-d, tryed this? WHERE a.id=b.providerId AND b.userid=c.id ..... instead of a.id=@id.
0

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.

1 Comment

Is it SQL Server? What error or incorrect response are you seeing. Can you create two test tables with data and test the same type of query?
0
DELETE t1, t2 
FROM t1 
INNER JOIN t2 
INNER JOIN t3
WHERE t1.id = t2.id AND t2.id = t3.id;

1 Comment

... sorry i need to delete multiple tables, not one table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.