寻高手解些问题
表A:ZT(帐套) ID(编号) NAME(名称)
zt001 02001 ...
zt001 02002 ...
zt001 02003 ...
zt001 02004 ...
zt001 02005 ...
zt002 03 ...
zt003 023 ...
..... ... ...
表B:S_ZT(原来的帐套) S_ID(原来的编号) D_ID(现在的编号)
zt001 02001 8888 原来zt001帐套的02001转为8888
zt001 02002 9999 原来zt001帐套的02002转为9999
zt001 all 1234 表示余下的全部转为1234
zt002 03 3434 原来zt002帐套的03转为3434
写select把表A的ID按表B的要求返回
------解决方案--------------------这样吗!?
select case when ZT= 'zt001 ' and ID= '02001 ' then '8888 '
when ZT= 'zt001 ' and ID= '02002 ' then '9999 '
when ZT= 'zt001 ' and ID= '03 ' then '3434 '
else '1234 ' end as D_ID
from 表A
------解决方案--------------------select S_ZT,S_ID,D_ID =
case when (S_ZT= 'zt001 ' and S_ID= '02001 ') then '8888 '
case when (S_ZT= 'zt001 ' and S_ID= '02002 ') then '9999 '
case when (S_ZT= 'zt002 ' and S_ID= '03 ') then '3434 '
else '1234 '
end
from 表A
------解决方案--------------------update A set
ID= '8888 '
where ZT= 'zt001 ' and ID= '02001 '
update A set
ID= '9999 '
where ZT= 'zt001 ' and ID= '02002 '
update A set
ID= '1234 '
where ZT=