I have a 2 tables MST_customer and TRN_sales in my database with corrupt entries. The next query returns the corrupt entries:
SELECT TRN_sales.cust_no
FROM MST_customer
RIGHT OUTER JOIN TRN_sales
ON MST_customer.cust_no = TRN_sales.cust_no
WHERE MST_customer.cust_name IS NULL;
I tried to delete them executing:
DELETE FROM mydbB.TRN_sales
WHERE TRN_sales.cust_no IN (
SELECT TRN_sales.cust_no
FROM MST_customer
RIGHT OUTER JOIN TRN_sales
ON MST_customer.cust_no = TRN_sales.cust_no
WHERE MST_customer.cust_name IS NULL
);
But I get the next error:
You can't specify target table 'TRN_sales' for update in FROM clause
How can I resolve this problem ?