anastasiasoul
asked on
SQL DELETE
Hi, I need to delete * from wnight for admission.outdate more than one month old.
I have got the qry, but when i try to execute it there is an error message:
You can't specify target table 'wnight' for update in FROM clause
Cannot figure out where the problem is.
I have got the qry, but when i try to execute it there is an error message:
You can't specify target table 'wnight' for update in FROM clause
Cannot figure out where the problem is.
DELETE
FROM wnight
WHERE wnight.adno IN
(SELECT wnight.adno
FROM
wnight,
admission,
currentdate
WHERE
admission.adno=wnight.adno
AND admission.outdate< SUBDATE(currentdate , INTERVAL 1 MONTH));
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you for a quick and accurate solution
You cannot update a table and select from the same table in a subquery in MySql.
I can't figure out the easy reformulation of your query. There, however is a hack that will probably make your code work.
Open in new window