0

I know that there is a lot of ways to delete data from mysql table using php, and also there is a lot of thread in this forum on 'how to delete data from mysql tables', but i want something else..

i use this query

$smt=$conn->prepare("SELECT * FROM post,images WHERE post.Id=images.Id");
$smt->execute();

to get data from multiple mysql tables and it works like charm, but when i try this query

$statement=$conn->prepare("DELETE FROM post,images WHERE post.Id=images.Id AND post.Id='".$id."'");
$statement->execute();

to delete data from multiple tables then it will not working, but if i tr like this

$statement=$conn->prepare("DELETE FROM post WHERE post.Id='".$id."'");
    $statement->execute();

then it will works fine and good, but i want to delete the data like the above way.....

Any help will be appreciated....

  • 3
    Please look at http://stackoverflow.com/questions/4839905/mysql-delete-from-multiple-tables-with-one-query – D4V1D Mar 24 '15 at 16:27
  • You need to write individual delete statements for each table or set up foreign key constraints with ON DELETE CASCADE option. – Maximus2012 Mar 24 '15 at 16:29

0 Answers0