开发者

Cross table update query in MySql

开发者 https://www.devze.com 2022-12-12 21:09 出处:网络
I can execute this kind of query in SQL Server: update tblmembers set hits_archived = (select count(*)

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

精彩评论

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