954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Delete from two tables

can someone help me with this pls..

DELETE FROM site_post, site_comments WHERE site_post.id=$id AND site_comments.matchid=$id


needing to delete two rows one from each table.

reco21
Light Poster
33 posts since Jan 2011
Reputation Points: 10
Solved Threads: 1
 

IIRC, this only works if the column names are the same in both tables.

Another option would be to create a foreign key between the two columns with ON DELETE CASCADE.

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You