Prellyan Posted July 15, 2009 Share Posted July 15, 2009 Hey there ... There seems to be a few ways to do this however i am still a little confused. I have two tables both have a common id field so to delete i thought would just be simple DELETE auctionpropertyaddressdata,auctionpropertyimages FROM auctionpropertyaddressdata JOIN auctionpropertyimages ON auctionpropertyid WHERE auctionpropertyid=%s not so ... can anyone resolve this for me? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/166044-delete-from-two-2-tables/ Share on other sites More sharing options...
phporcaffeine Posted July 15, 2009 Share Posted July 15, 2009 http://dev.mysql.com/doc/refman/5.0/en/delete.html Quote Link to comment https://forums.phpfreaks.com/topic/166044-delete-from-two-2-tables/#findComment-875679 Share on other sites More sharing options...
Prellyan Posted July 15, 2009 Author Share Posted July 15, 2009 Thanks for that - but i am seriously stuck on the syntax can you offer any other help as well please? thanks Quote Link to comment https://forums.phpfreaks.com/topic/166044-delete-from-two-2-tables/#findComment-875689 Share on other sites More sharing options...
phporcaffeine Posted July 15, 2009 Share Posted July 15, 2009 DELETE auctionpropertyaddressdata, auctionpropertyimages FROM auctionpropertyaddressdata INNER JOIN auctionpropertyimages WHERE auctionpropertyaddressdata.id=auctionpropertyimages.id; Quote Link to comment https://forums.phpfreaks.com/topic/166044-delete-from-two-2-tables/#findComment-875691 Share on other sites More sharing options...
Prellyan Posted July 15, 2009 Author Share Posted July 15, 2009 that worked but it wiped out ALL records not just the selected recordID DELETE auctionpropertyaddressdata,auctionpropertyimages FROM auctionpropertyaddressdata INNER JOIN auctionpropertyimages ON auctionpropertyid WHERE auctionpropertyid=%s gives me this error Column 'auctionpropertyid' in where clause is ambiguous where just the recordID from the link is deleted not the entire set thanks for help thusfar --- i am sure we can get it sorted Quote Link to comment https://forums.phpfreaks.com/topic/166044-delete-from-two-2-tables/#findComment-875698 Share on other sites More sharing options...
fenway Posted July 18, 2009 Share Posted July 18, 2009 Use table aliases and prefixes. Quote Link to comment https://forums.phpfreaks.com/topic/166044-delete-from-two-2-tables/#findComment-877693 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.