I have a Query with Union-Statement
where I retrieve all UserIds
which are present in the Requester
& Provider
Column
of the table
Orders.
SELECT Requester
FROM Orders
UNION
SELECT Provider
FROM Orders
This query yields some 7000 results in under a second.
Now i have table named 'Persons
' where those UserIds
are linked to the persons data
.
Using the above query i would like to clean this table and only keep the UserIds that are present in the result of the union-statement above.
So I made the following delete-statement:
DELETE FROM
Persons
WHERE
UserId NOT IN(
SELECT Requester
FROM Orders
UNION
SELECT Provider
FROM Orders
)
Yet this query refuses to execute (even after 5 minutes waiting). What could be the reason for my query to fail? Am I not allowed to use UNION
as Statement in the subquery here?
Note: following MySQL DELETE FROM with UNION subquery by IN condition didn't solve it for me.