开发者

Cross table update query in MySql

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 vers开发者_JAVA技巧ion for the right syntax to use near 'select count(*) from tblhits where tblhits.target_id=tblmem


This can also be done with a subquery using MySQL.

Subquery Syntax

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜