MySql中的跨表更新查询
我可以在 SQL Server 中执行这种查询:
update tblmembers
set hits_archived =
(select count(*)
from tblhits
where tblhits.target_id=tblmembers.id
and tblhits.hitdate < '2009-11-01')
where tblmembers.regdate < '2007-09-28'
How can I do this in MySql 4.0.23? 我尝试执行该查询,但它返回此错误消息:
您的 SQL 语法中有错误。检查与您的 MySQL 服务器版本相对应的手册,了解在 'select count(*) from tblhits where tblhits.target_id=tblmem 附近使用的正确语法
I can execute this kind of query in SQL Server:
update tblmembers
set hits_archived =
(select count(*)
from tblhits
where tblhits.target_id=tblmembers.id
and tblhits.hitdate < '2009-11-01')
where tblmembers.regdate < '2007-09-28'
How can I do this in MySql 4.0.23?
I tried to execute the query, but it returned this error message:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select count(*) from tblhits where tblhits.target_id=tblmem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这也可以通过使用 MySQL 的子查询来完成。
子查询语法
This can also be done with a subquery using MySQL.
Subquery Syntax