Trying to delete rows that exist in both temp_abstract table and abstract table.
DELETE FROM temp_abstracts WHERE application_id IN (SELECT temp_abstracts.application_id, abstracts.application_id FROM temp_abstracts INNER JOIN abstracts ON temp_abstracts.application_id=abstracts.application_id) ;
When I just run what’s inside the parentheses it returns what I want, but adding a delete from where seems to throw this error. Any help?
Advertisement
Answer
You can use EXISTS
instead :
DELETE ta FROM temp_abstracts ta WHERE EXISTS (SELECT 1 FROM abstracts a WHERE a.application_id = ta.application_id);
Sub-query will return only one expression while using IN
OR NOT IN
.