使用WHERE SELECT子查询错误进行MYSQL更新 [英] MYSQL update with WHERE SELECT subquery error
本文介绍了使用WHERE SELECT子查询错误进行MYSQL更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在选择子查询以在UPDATE
上工作时遇到问题.我正在尝试以下操作:
I have an issue with getting select sub-queries to work on an UPDATE
. I'm trying something like the following:
UPDATE foo
SET bar=bar-1
WHERE baz=
(
SELECT baz
FROM foo
WHERE fooID='1'
)
其中foo
是具有主键fooID
的表名. bar
和baz
的类型为INT.执行此操作时,出现以下错误:
Where foo
is the table name with primary key fooID
. bar
and baz
are of type INT. When executing this I get the following error:
Error: A query failed. You can't specify target table 'foo' for update
in FROM clause
推荐答案
查看全文