You can't specify target table for update in FROM clause
·
You can't specify target table '表名' for update in FROM clause
翻译为:不能先select出同一表中的某些值,再update这个表(在同一语句中)
错误写法:
UPDATE snc_visualpanel_tree
SET node_type = '1' WHERE parentid IN (
SELECT(
SELECT flid
FROM snc_visualpanel_tree
WHERE type = 1 AND parentid = '1'
)
);
正确写法:
UPDATE snc_visualpanel_tree
SET node_type = '1'
WHERE parentid IN (
SELECT aa.flid FROM
(
SELECT flid FROM
snc_visualpanel_tree
WHERE type = 1 AND parentid = '1'
) aa
);
也就是说:把结果集当作一个表,自我查询一遍
格式为:SELECT a.StudentResult FROM (结果集)a
更多推荐
已为社区贡献1条内容
所有评论(0)