请教各位如何写这个where条件令到这条语句可以根据一例为模糊条件进行修改本表里另一例的数据(50分)

X

xej

Unregistered / Unconfirmed
GUEST, unregistred user!
本人在sql server 2000后台写了一个要修改t_fn_zhechangfuzhaibiao表的存储过程,过程中需要根据t_fn_zhechangfuzhaibiao表的一例名gongsi为模糊条件进行修改本表里niancushu例的数据,gongsi例的数据是int型,其中的数据为(101,201,209),(102,509,406)等。例如,假设表中gongsi例其中一个数据是101,102,109,而要实现修改的语句如下:<br> update t_fn_zhechangfuzhaibiao set niancushu=(select case b.direction when 1 then sum(a.debitamount)-sum(a.creditamount) when -1 then sum(a.creditamount)-sum(a.debitamount) end<br> &nbsp; from t_fn_voucher_detail as a <br> &nbsp;left join t_bs_accountingsubject as b on b.id=a.bs_accountingsubject_id <br> &nbsp;left join t_fn_voucher as c on c.id=a.fn_voucher_id <br>where b.code='101'+'%' or b.code= '110'+'%' or b.code='203'+'%')<br> &nbsp;group by b.direction<br>请教各位如何写这个where条件令到这条语句可以根据gongsi为模糊条件进行修改本表里niancushu例的数据。<br><br>我的需求是,在t_fn_zhechangfuzhaibiao表里,根据gongsi为模糊条件进行修改本表里niancushu例的数据,而gongsi例数据是int型,例如列数据为(101,201,209),(102,509,406),(103,104,106),这些101,102是另一个表的id号,它有子id,如101有101001,101000001等,查询101时把它的子id行也要一起查询.<br> update t_fn_zhechangfuzhaibiao set niancushu=(select case b.direction when 1 then sum(a.debitamount)-sum(a.creditamount) when -1 then sum(a.creditamount)-sum(a.debitamount) end<br> &nbsp; from t_fn_voucher_detail as a <br> &nbsp;left join t_bs_accountingsubject as b on b.id=a.bs_accountingsubject_id <br> &nbsp;left join t_fn_voucher as c on c.id=a.fn_voucher_id <br>where b.code='101'+'%' or b.code= '110'+'%' or b.code='203'+'%')<br> &nbsp;group by b.direction<br>只是其中gongsi一个例名的修改一行的语句,如何修改这条语句令它可以修个整个t_fn_zhechangfuzhaibiao表里的数据.
 
真长的问题,<br>一句话,模糊查询语句,格式:<br>like % &nbsp; %<br>示例:<br>select * from table where *** like% #### % <br>后一段太长了,没时间看...
 
顶部