update stock_item d,stock_btk t
set d.out_num=IF(d.out_num-t.STORENUM<0,0,d.out_num-t.STORENUM)
,d.ky_num=d.ky_num+t.STORENUM
,d.sj_num=d.sj_num+t.STORENUM
,d.mss_ck_num=IF(d.mss_ck_num-t.STORENUM<0,0,d.mss_ck_num-t.STORENUM)
,t.is_exe='1'
where t.ORGBILLROWID=d.BILLROWID and d.stock_id=t.ORGBILLID
and t.is_exe='0'
and t.gen_code='gen_code'
UPDATE tdb_goods INNER JOIN tdb_goods_catesON goods_cate = cate_name
SET goods_cate = cate_id ;