Table1有两个字段A和B
Table2就一个字段C
全都是int的数字。现在想做的是:把所有的B遍历一遍,如果B in C,就set A=1
请问这个语句该怎么写啊??

解决方案 »

  1.   

    update table1 a1 set A=1 where exists(select 1 from table2 where charindex(a1.B,C)>0)
      

  2.   

    select *,[查询]=case when exists(select 1 from b where c=a.b) then 1 else 0 end--有为1没有为0
    from
    a
      

  3.   

    update Table1 set A=1 from Table1 a inner join Table2 b on a.B=b.C
      

  4.   


    Table1有两个字段A和B 
    Table2就一个字段C 
    全都是int的数字。 现在想做的是:把所有的B遍历一遍,如果B   in   C,就set   A=1 update  table2 set A=1 where B in(select C from table1)
      

  5.   


    或者:
    update  table1 set A=1 from table1 a where exists (select 1 from table2 where a.b=c)