同一个where为什么写两次? 
问题在外面那个where上

解决方案 »

  1.   

    语句没有问题,dept.dept_name 是否存在呢?
      

  2.   

    update cpms_reportformathead  set cfh_asdept= (select dept from dept  where cpms_reportformathead.cfh_asdept = dept.dept_name )
    where cpms_reportformathead.cfh_asdept=dept.dept_name
    --------------
    后面的where cpms_reportformathead.cfh_asdept=dept.dept_name有问题,
    换成where exists(select 1 from dept  where dept.dept_name=cpms_reportformathead.cfh_asdept)
      

  3.   

    提示的是在這個地方的dept.dept_name嗎?
    where cpms_reportformathead.cfh_asdept=dept.dept_name
    你把這一行去掉,看有什麽提示
      

  4.   

    外面的那个WHERE语句去掉应该就没问题了update cpms_reportformathead  set cfh_asdept= (select dept from dept  where cpms_reportformathead.cfh_asdept = dept.dept_name )
      

  5.   

    update cpms_reportformathead  
       set cfh_asdept= (select dept 
                          from dept  
                         where cpms_reportformathead.cfh_asdept = dept.dept_name )
    where cpms_reportformathead.cfh_asdept IN(select dept.dept_name 
                                                from dept);
      

  6.   

    看看楼上说的情况
    还有这个:
    update cpms_reportformathead
       set cfh_asdept = (select dept--------------有没有这个字段名吗?
                           from dept
                          where cpms_reportformathead.cfh_asdept = dept.dept_name)
     where cpms_reportformathead.cfh_asdept = dept.dept_name
      

  7.   

    呵呵,赞同 waterfirer(水清)的改法
      

  8.   

    呵呵,
    原来是语句有问题的!!!
    waterfirer(水清) 的正确!!!
      

  9.   

    外面的WHERE语句去掉,所要的结果就出问题了,原来的意思是符合条件才更新,
    如果去掉,变成全部记录更新了。
    水清的语句正确
      

  10.   

    update cpms_reportformathead  a 
    set cfh_asdept=(select dept 
                    from dept b 
                    where a.cfh_asdept = b.dept_name )