Each of the below lines work individually but I would like to combine them into one query.
$query4="DELETE FROM a WHERE email = '$email'";
$query2="DELETE FROM b WHERE email = '$email'";
$query3="DELETE FROM c WHERE email = '$email'";
$query1="DELETE FROM d WHERE email = '$email'";
$result = mysqli_query($con, $query[1-4, depending]) or die(mysqli_error($con));
I have tried a number of different ways. From the MySQL docs, it should be as simple as:
$query="DELETE FROM a, b, c, d WHERE email = '$email'";
$result = mysqli_query($con, $query) or die(mysqli_error($con));
I have also tried it with backticks, as:
$query="DELETE FROM `a`, `b`, `c`, `d` WHERE email = '$email'";
And I tried concatenating the individual four lines into a long semi-colon delimited string.
Everything but the four individual lines gives me a SQL syntax error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE email = 'xxxxxx@yyyyyyyyy.com'' at line 1.
I checked that the db user has DELETE permissions (and of course they do, since it works fine when run individually).
It's relatively simple to do this in separate statements but I'm just sort of baffled as to why it's not working at this point. Would like to solve this just for curiosity's sake.
I did find the mysqli_multi_query()
command...is the "...a, b, c, d..." part being seen by mysqli as separate queries?
Thank you for any help you can provide! (Please note I've left out db connection lines as it's connecting fine.) Again...thank you!