I have got MySQL error \"You can\'t specify target table \'tasks\' for update in FROM clause\" running the following query:
DELETE FROM tasks WHERE tasks.id
It's because you're specifying the tasks table more than once. Try:
DELETE FROM tasks USING deadlines WHERE deadlines.id = tasks.deadline_id AND DATE_ADD(tasks.created_at, INTERVAL deadlines.duration DAY) <= NOW()