I'm running a delete query that deletes rows from multiple tables and I've been using this syntax:
$sql = "DELETE from table1, table2 using table1, table2 WHERE table1.user_id=$user AND table2.user_id=$user";
This works fine if the user_id is in both tables. But sometimes it isn't, and in those cases I'd still like to have the record deleted in the table where it exists.
I tried switching the AND to an OR statement, but this ended up deleting all values in the table where the user_id didn't exist. (not sure I understand that)
I know this could easily be done with two separate sql statements, but for various reasons I'm trying to keep it to one statement.