【发布时间】:2013-09-30 18:09:28
【问题描述】:
我正在尝试使用Visual Studio 2010 (c#) 更新我的mysql 表“upproj”。
我想执行以下查询:
string Query = " update tlog.upproj set summ=(select sum(grade) from tlog.upproj group by ams having count(*) =2); ";
但我得到错误
"You can't specify target table 'upproj' for update in FROM clause".
当我在 Mysql 查询浏览器上执行上一个查询时,我没有收到任何错误,但我的项目需要从 Visual Studio 执行此查询。
有没有办法解决这个问题?
【问题讨论】:
-
感谢编辑:)
-
UPDATE查询的具体目的是什么?如果 起作用,它将更新表中的每一行,因为它没有设置WHERE子句。 -
并在类似问题上查看this answer。
-
update 的目的是给 summ 列设置值。我通过 Visual Studio 执行此操作,而不是在计数子查询中使用“2”,而是使用在 vs 项目中给出的变量。对不起我的英语不好。
标签: c# mysql visual-studio-2010