I have two tables with data. I want to delete rows in both tables. But I have foreign keys between them. How can I do this?
departure
id departure_d
Please try this, hope it will help.
DELETE FROM departure, departure_time
USING departure
INNER JOIN departure_time
WHERE departure_date = '2016-09-30'
AND departure_time.id = departure.id
Or
DELETE FROM departure, departure_time
USING departure
INNER JOIN departure_time
WHERE departure_date = '2016-09-30'
AND departure_time.departure_id = departure.id
Or you can use ON DELETE CASCADE
that will do work automatically for you .