以下语句是否有语法错误?
update a set a.funitid=b.fbaseunit
from T_BD_MaterialInventory a,T_BD_Material b
where b.fid=a.fmaterialid and b.fbaseunit <> a.funitid
update a set a.funitid=b.fbaseunit
from T_BD_MaterialInventory a,T_BD_Material b
where b.fid=a.fmaterialid and b.fbaseunit <> a.funitid
set a.funitid=(select b.fbaseunit
from T_BD_Material b
where b.fid=a.fmaterialid
and b.fbaseunit <> a.funitid )
set a.funitid=(select fbaseunit
from T_BD_Material b
where a.fmaterialid = b.fid
and a.funitid <> b.fbaseunit and rownum = 1)
加个rownum = 1 就在查询出在对应表T_BD_Material中多行fbaseunit中的第一行数据如果子查询返回多行数据 就会报错 单行查询返回多个值 必须只能返回一行
set a.funitid=(select b.fbaseunit
from T_BD_Material b
where b.fid=a.fmaterialid
and b.fbaseunit <> a.funitid
and rownum = 1)这个应该是可以的
set a.funitid=(select distinct b.fbaseunit
from T_BD_Material b
where b.fid=a.fmaterialid
and b.fbaseunit <> a.funitid
)试试。