Thursday, December 20, 2012

delete data from two tables at the same time in mysql


delete record from two table in same time in mysql 

it is useful when we create two related table in mysql   

 // with inner join 

DELETE tb1, tb2 FROM tb1 inner JOIN tb2  WHERE tb1.id=tb2.tb1id and tb1.id=1



 // with left or Right Join 

DELETE tb1, tb2 FROM tb1 LEFT JOIN tb2 ON tb1.id=tb2.tb1id  WHERE tb1.id=1

No comments:

Post a Comment

If you Satisfied , Please Leave a comment