I have the following queries:
DELETE FROM server_N1 where vencimiento <= '2015/01/08';
DELETE FROM server_N2 where vencimiento <= '2015/01/08';
DELETE FROM server_N3 where vencimiento <= '2015/01/08';
...
DELETE FROM server_N11 where vencimiento <= '2015/01/08';
I want to convert theses queries in only one query. I tried the following but it doesn't work:
DELETE
N1, N2, N3, N4, N5, N6, N7, N8, N9, N10, N11 FROM server_N1 N1, server_N2 N2, server_N3 N3, server_N4 N4, server_N5 N5, server_N6 N6, server_N7 N7, server_N8 N8, server_N9 N9, server_N10 N10, server_N11 N11
WHERE
(N1.vencimiento <= '2015/01/08') AND
(N2.vencimiento <= '2015/01/08') AND
(N3.vencimiento <= '2015/01/08') AND
(N4.vencimiento <= '2015/01/08') AND
(N5.vencimiento <= '2015/01/08') AND
(N6.vencimiento <= '2015/01/08') AND
(N7.vencimiento <= '2015/01/08') AND
(N8.vencimiento <= '2015/01/08') AND
(N9.vencimiento <= '2015/01/08') AND
(N10.vencimiento <= '2015/01/08') AND
(N11.vencimiento <= '2015/01/08');
How can I do it?
Edit: The problem is when I trying to join all queries in only one, I receive the following 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 'DELETE FROM server_N2 WHERE vencimiento <= '2015/01/08'; DELETE FROM server_N3 W' at line 1
Edit: Code:
$fechaactual = '2015/01/08';
$delete = mysqli_query($con, "DELETE FROM server_N1 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N2 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N3 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N4 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N5 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N6 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N7 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N8 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N9 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N10 WHERE vencimiento <= '{$fechaactual}'; DELETE FROM server_N11 WHERE vencimiento <= '{$fechaactual}'");