表B 字段有BID, SM, CONNTENT等。 表A 字段有 AID, SM , STATUS 等
现要求,根据B表SM字段值,如果A表中有记录与B表中的SM值相同,就把A表该条记录的STATUS值从N改成Y。
望赐教,小弟菜鸟。  

解决方案 »

  1.   

    update A set A.STATUS='Y' where A.SM=B.SM
      

  2.   

    update A set status='Y' from B inner join A on A.sm=B.sm and A.status='N'
      

  3.   


    update A set status='Y' from B left join A on A.sm=B.sm where A.status='N'update A set A.STATUS='Y' where A.SM=B.SM and A.status='N'
      

  4.   

    UPDATE TA SET status='Y' FROM B WHERE A.SM=B.SM AND A.STATUS='N'
      

  5.   

    update A set status='Y' from B left join A on A.sm=B.sm where A.status='N'update A set A.STATUS='Y' where A.SM=B.SM and A.status='N'
      

  6.   

    update A set status ='Y' from A where exists(select 1 from B where SM=A.SM)
      

  7.   

    update A set status ='Y' from A where exists(select 1 from B where SM=A.SM)
      

  8.   

    update A set status ='Y' from A where exists(select 1 from B where SM=A.SM)