先保证语法无错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

解决方案 »

  1.   

    --  把 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 好象你的语句中有 全角空格。
      

  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
      

  3.   

    try this,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
      

  4.   

    update table  set see =1 
    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
      

  5.   

    如果表中的字段或者表名用的是SQL系统的关键字,可以用"[]"括起来,建议表名和字段不要用系统的关键字..
      

  6.   

    没有这么直接写过。 update的时候都是from TB 来直接连接表。
      

  7.   

    如果表中的字段或者表名用的是SQL系统的关键字,可以用"[]"括起来,建议表名和字段不要用系统的关键字..