Now, I understand the error, Mysql is confused as to which titleId to use to delete. All the tables have a titleId column and their value will always be the same for each title.
So the question is how do I get around this problem without having to do individual delete queries for each table?
Damn, my prepared statement solution has a problem in that mysql gives me an error because PDO will escape the name of the table and put it in single quotes. Mysql doesn’t like that at all.
otherwise you need to join all those tables properly, and then there is the issue of missing values, where if one of the joined tables doesn’t have a row for that value, then the join will fail for that value, and none of the other rows which did have a value will get deleted
However, it sounds like a good occasion to use PDO prepared statements. However I’m not sure how the syntax would be. I create 1 prepare statement and then just run the subsquent execute statement with the array containing the table name right?
$con->prepare("DELETE FROM :table WHERE titleId = :number");
$myArr = array(':table'=> 'actor', ':number'=> $number);
$con->execute($myArr);
// change $myArr values and...
$con->execute($myArr)