steveh62 Posted November 18, 2008 Share Posted November 18, 2008 I know this might be in the forum somewhere. BUT I have 2 tables that I want to Delete from based on a variable passed in the url...thats done... its just the php mysql structure. on table has different field names to the other yet contains the same data - for reasons known to myself. so, how do I do a Delete on two tables? the code below knocks me out and does nothing <?php $sql="delete FROM category, products WHERE category.ID AND products.CATID = '$catid"; $result = mysql_query($sql); echo '<p class="green">Gallery folder and contents deleted!</p>'; ?> Link to comment https://forums.phpfreaks.com/topic/133209-solved-mysql-delete-on-two-tables/ Share on other sites More sharing options...
premiso Posted November 18, 2008 Share Posted November 18, 2008 I do not think you can do a join delete. I am not sure of this but I think you need 2 seperate statements. <?php $sql="delete products WHERE products.CATID = $catid"; $sql2="delete category WHERE category.ID = $catid"; ?> If you can do it in one blow your SQL is wrong. <?php $sql="delete category, products WHERE category.ID = $catid AND products.CATID = $catid"; ?> You ahve to set it equal to $catid each time. Link to comment https://forums.phpfreaks.com/topic/133209-solved-mysql-delete-on-two-tables/#findComment-692814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.