子查询的where条件比 update 的where 条件多 不是有b.agentno like'9___'  and a.isactive='Y' and b.isactive='Y'  第一个回复 因为没细看  sorry

解决方案 »

  1.   

    select    b.agentno    from          tb_userinfo  b,   tb_shop a     where  b.agentno like'9___'  and a.isactive='Y' and b.isactive='Y' and a.pk_tw_user_id=b.tu_user_bh 这个条件关联出来的数据有空值
    但是 
    a..pk_tw_user_id 应该是主键不能为空!1.解决办法  要不核查B表查出来的数据为啥为空,看是否是错误数据
    2.把A表主键去了,
      

  2.   

    你这样条件不太多 而且效率也低 试试这样的update a
       set a.pk_tw_user_id = b.agentno from tb_shop a, tb_userinfo b
     where a.pk_tw_user_id = b.tu_user_bh
       and b.agentno like '9___'
       and a.isactive = 'Y'
       and b.isactive = 'Y'
      

  3.   

    原来是oracle的  那你把条件补齐应该可以吧
      

  4.   

    update tb_shop a
       set a.pk_tw_user_id =
           (select b.agentno
              from tb_userinfo b
             where a.pk_tw_user_id = b.tu_user_bh)
     where a.isactive = 'Y' and exists (select 1
               from tb_userinfo b
              where a.pk_tw_user_id = b.tu_user_bh
                and b.agentno like '9___'
                and b.isactive = 'Y')
    这样应该可行吧
      

  5.   

    sql语句 后面加上:where s.pk_tw_user_id = (select distinct u.tu_user_bh 
         from tb_userinfo u where u.agentno like'9___'  and s.isactive='Y' and u.isactive='Y' and s.pk_tw_user_id=u.tu_user_bh)