Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi frnds,

how can we delete a record at a time in two tables using joins.

what's wrong in this query
Query:
SQL
delete from admin from client c INNER JOIN admin a on a.mstr_id=c.mstr_id where c.padm_id=2020

Please correct this one
Posted
Updated 21-Dec-11 1:49am
v2

You should have a foreign key to the other table and configure it to cascade delete. In this way the referenced record will be deleted if there are no more references to it. Have a look at the link for more info:
http://www.mssqlcity.com/Articles/General/using_constraints.htm[^]

Good luck!
 
Share this answer
 
Comments
swarup65 21-Dec-11 8:01am    
hi,
how can we will apply delete cascade
E.F. Nijboer 21-Dec-11 12:41pm    
Check out the link

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