There are two tables.
id| name | date 1| item1| 2013-10-06 08:11:25 2| item2| 2013-03-06 08:11:25 3| item3| 2013-06-04 08:11:25 and
id|id_s | name | date 1| 2 | name1| 2013-03-06 08:11:25 2| 1 | name2| 2013-10-06 08:11:25 3| 2 | name2| 2013-01-02 08:11:25 It all works like this:
The second table is taken, the first LEFT JOIN is added and something is output. (The second table's id_s points to the first id)
How to delete from the FIRST table those records that are not referenced from the second, or the data in the date fields of both tables contain a date more than a month ago?
Those. in the example, delete the third row from the first table, because there are no links on it in the second table, and the second row, because the date is overdue.
select ... fromexpression todelete from. - Yura Ivanov