I have two tables as follows
tbl1 tbl2
id article_id
title, image
whole_news
tags,
author,
older (datetime)
where tbl1.id -> tbl2.article_id
How to delete records from both tables where older is < 2008-02-10 00:00:00 ?
See my answer to a similar question here.
To summarize, it would look like
delete s, r from tbl1 s left join tbl2 r on s.id = r.article_id where s.older < str_to_date('2008-02-10 00:00:00', '%Y-%m-%d %H:%i:%S');
But the better solution would be a foreign key constraint with an on delete cascade, if that is an option, then just delete from tbl1 with the appropriate where clause.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With