7
I was using the following code in mysql:
delete from aluno where id=(select MAX(id) from aluno);
But the following error appears:
Error Code: 1093. You can’t specify target table 'student' for update in FROM clause.
7
I was using the following code in mysql:
delete from aluno where id=(select MAX(id) from aluno);
But the following error appears:
Error Code: 1093. You can’t specify target table 'student' for update in FROM clause.
9
As Rray said, it is not possible, but there are alternatives... An alternative would be to use variables:
set @val_max = (select max(id) from aluno );
delete FROM aluno where id = @val_max;
I hope I’ve helped!
Any doubt, leave a comment.
3
Unable to perform a DELETE
with a subquery specifying the same table, as it says documentation.
You cannot delete from a table and select from the same table in a subquery.
0
You can sort by the example table id
DELETE FROM table ORDER BY the field DESC|ASC
Browser other questions tagged mysql sql
You are not signed in. Login or sign up in order to post.
The clause
ORDER BY
does not apply toDELETE
. If this worked, it would simply delete all records from the table.– Victor Stafusa