I have a table called "downloads" with two columns of the foreign key - "user_id" and "item_id". I need to select all the rows from this table and delete the rows in which the user or the item in question no longer exists. (Look at the user, and if he is not found, delete the line in "downloads", then find the item, and if he is not found, delete the line in "downloads").
This is 3.4 million lines, so all my scripting solutions took 6 hours. I hope there is a faster, only SQL way?
source
share