Jump to content

Recommended Posts

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.