I'm getting error below for second query at the bottom. Any idea idea why?
Thanks
ERROR: Error Number: 1093
You can't specify target table 'menus' for update in FROM clause
WORKS:
INSERT INTO menus
(name, controller, parent)
VALUES
('A', 'B', (SELECT id FROM menus menus_alias WHERE SHA1(menus_alias.id) = '1'))
BOTH DON'T WORK:
UPDATE menus SET
parent = (SELECT id FROM menus menus_alias WHERE SHA1(menus_alias.id) = '1')
WHERE SHA1(id) = '5'
UPDATE menus menus_alias SET
menus_alias.parent = (SELECT id FROM menus WHERE SHA1(id) = '1')
WHERE SHA1(menus_alias.id) = '5'
Checked out these:
- Mysql error 1093 - Can't specify target table for update in FROM clause
- mysql - cant specify target table for update in from clause
- Error (1093):You cant update target table for update in FROM Clause
- ERROR 1093 (HY000): You can't specify target table 'a' for update in FROM clause
and some others