Click here to Skip to main content
15,905,781 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir,
how to delete from more than two tables using single query
Posted

You can't delete from anything with any query.

A DELETE statement can basically only delete from one table, but if your system and architecture allow it, you can turn on cascaded deletes, but that's generally a bad idea.

If your system allows it, you may be able to pass multiple statements (of whatever kind you need) at once.

E.g. DELETE FROM Table1 ; DELETE FROM Table 2 ... ; DELETE FROM Tablen
 
Share this answer
 
Comments
vineethnair 7-Dec-13 1:58am    
ok..can use inner join to delete from more than tables
vineethnair 7-Dec-13 2:17am    
sir,
you are right its a bad idea.if you know another method please help me..
U can use join for that....


Delete from table_name
from table_name a inner join table_name b on a.id=b.id


Hope this will help you ....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900