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)
提示的是在這個地方的dept.dept_name嗎? where cpms_reportformathead.cfh_asdept=dept.dept_name 你把這一行去掉,看有什麽提示
外面的那个WHERE语句去掉应该就没问题了update cpms_reportformathead set cfh_asdept= (select dept from dept where cpms_reportformathead.cfh_asdept = dept.dept_name )
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);
看看楼上说的情况 还有这个: 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 cpms_reportformathead.cfh_asdept=dept.dept_name有问题,
换成where exists(select 1 from dept where dept.dept_name=cpms_reportformathead.cfh_asdept)
where cpms_reportformathead.cfh_asdept=dept.dept_name
你把這一行去掉,看有什麽提示
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);
还有这个:
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
原来是语句有问题的!!!
waterfirer(水清) 的正确!!!
如果去掉,变成全部记录更新了。
水清的语句正确
set cfh_asdept=(select dept
from dept b
where a.cfh_asdept = b.dept_name )