Home Delete from different tables in one query with prepared statements
Reply: 0

Delete from different tables in one query with prepared statements

user577
1#
user577 Published in August 15, 2018, 9:02 am

I want to delete multiple records with a specified value (non-unique) in one table and delete the record with that same specified value (unique) in another table using a prepared statement. This is what I got,

$stmt = $conn->prepare("DELETE FROM Books WHERE Genre_ID=? AND FROM Library WHERE Genre_ID=?");
$stmt->bind_param("ii", $genreID, $genreID);    

The aim of the query would be to delete the specified Genre from the Library table by its ID and, of course, remove all the books from the Books table with that ID.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299756 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO