I have a database table called 'order' which references another table named 'delivery' through a foreign key. I need to delete deliveries modified before a certain date but I can't do so until I delete the orders that reference them.
So I need to delete orders where deliveries were modified before a certain date. I wrote the following query in MySQL:
DELETE FROM `order`,`delivery` WHERE order.delivery_id = delivery.id AND delivery.modifiedOn < '2016-2-28 23:59:59'
This is the syntax you are looking for:
DELETE o, d FROM `order` o JOIN `delivery` d ON o.delivery_id = d.id WHERE d.modifiedOn < '2016-02-29';
order. It is a reserved word in MySQL and a keyword in SQL. How about
JOINsyntax, even in non-