2个表 A表 B表
update A set aa = aa + 1 
where(select ba from B where bb= 0) = abA
aa int
ab int
B
bb int
ba int问题是select ba from B where bb= 0 返回多个值 而作为 A表的条件不行
爆的错:当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。

解决方案 »

  1.   

    try
    update A set aa = aa + 1 
    where exists (select ba from B where bb= 0 and ba = A.ab)
      

  2.   

    或者update A set aa = aa + 1 
    From A
    where exists (select ba from B where bb= 0 and ba = A.ab)
      

  3.   

    update A set aa = aa + 1 
    From A,B
    where  A.ab=B.ba and B.bb=0
      

  4.   

    update A set aa = aa + 1 
    where ba IN(select ba from B where bb= 0)
      

  5.   

    update A set aa = aa + 1 
    From A
    where exists (select 1 from B where bb= 0 and ba = A.ab)