34,593
社区成员
发帖
与我相关
我的任务
分享
update table as a set see =1 where exists (select 1 from table as b where a.username =b.username and convert(varchar(10),a.日期,121) =convert(varchar(10),b.日期,121) and b.type=1) and a.type=2
update a
set a.see=1
from [table] a
where exists
(select 1
from [table] b
where a.username=b.username
and convert(varchar,a.日期,121)=convert(varchar,b.日期,121)
and b.type=1) and a.type=2
UPDATE a
SET a.see=1
FROM [table] AS a INNER JOIN [table] AS b ON a.username = b.username
AND CONVERT(VARCHAR(10), a.日期, 121) = CONVERT(VARCHAR(10), b.日期, 121)
WHERE b.[type]=1 AND a.[type]=2
-- 把 table as a 中的 as a 去掉,再把子查询中的 a.col 都改成 table.col
update table
set see =1 where exists (select 1 from table as b where table.username =b.username and convert(varchar(10),table.日期,121) =convert(varchar(10),b.日期,121) and b.type=1)
-- 另外 ,如果非要使用别名形式,可以使用下列格式
update a
set a.see = 1
from table a , table b
where a.username =b.username
and convert(varchar(10),a.日期,121) =convert(varchar(10),b.日期,121
and b.type=1)
and a.type=2
-- PS 好象你的语句中有 全角空格。
UPDATE a
SET see = 1
FROM [table] AS a
WHERE EXISTS ( SELECT 1
FROM [table] AS b
WHERE a.username = b.username
AND CONVERT(VARCHAR(10), a.日期, 121) = CONVERT(VARCHAR(10), b.日期, 121)
AND b.type = 1 )
AND a.type = 2