先保证语法无错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
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
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 好象你的语句中有 全角空格。
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
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
where exists
(select 1 from table b where username =b.username and convert(varchar(10),日期,121) =convert(varchar(10),b.日期,121) and b.type=1)
and type=2