怎么对下句查出来的USER_TYPE 都置为1?
select  a.user_type from secu_user a ,secu_department b where a.parent_id=b.dept_id and b.dept_layer in (1,2,3,4) and a.user_login is not null 用UPDATE怎么实现?

解决方案 »

  1.   

    UPDATE secu_user a
       SET a.user_type = 1
     WHERE EXISTS (SELECT 1
                     FROM secu_department b
                    WHERE a.parent_id = b.dept_id AND b.dept_layer IN
                                                                     (1, 2, 3, 4))
       AND a.user_login IS NOT NULL
      

  2.   

    二楼是绝对的高手。
    向hebo学习
      

  3.   

    update secu_user set user_type=
    (select 1 from secu_user a ,secu_department b where a.parent_id=b.dept_id and b.dept_layer in (1,2,3,4) and a.user_login is not null );
      

  4.   

    update secu_user a set user_type= 
    (select 1 from secu_department b where a.parent_id=b.dept_id and b.dept_layer in (1,2,3,4) and a.user_login is not null );