'hzmat_no' = case
when SUBSTRING(miodt.vou_no, 1,1)='H'and miodt.mat_no=''then cutcurdt.mat_no
when SUBSTRING(miodt.vou_no, 1,1)='C' and miodt.mat_no='' then bultbj.mat_no else miodt.mat_no end
就是說,我在SQL語句中加了條件選擇,然后需要按'hzmat_no'加where條件.
when SUBSTRING(miodt.vou_no, 1,1)='H'and miodt.mat_no=''then cutcurdt.mat_no
when SUBSTRING(miodt.vou_no, 1,1)='C' and miodt.mat_no='' then bultbj.mat_no else miodt.mat_no end
就是說,我在SQL語句中加了條件選擇,然后需要按'hzmat_no'加where條件.
select * from
(
select MIODT.* ,'hzmat_no' = case
when SUBSTRING(miodt.vou_no, 1,1)='H'and miodt.mat_no=''then cutcurdt.mat_no
when SUBSTRING(miodt.vou_no, 1,1)='C' and miodt.mat_no='' then bultbj.mat_no else miodt.mat_no end
from miodt
left join cutcurdt on miodt.vou_no=cutcurdt.vou_no and miodt.part_no=cutcurdt.part_no
left join bultbj on miodt.vou_no=bultbj.bul_no and miodt.part_no=bultbj.part_no ) a
WHERE hzmat_no='A01010902'
select * from
(
select MIODT.* ,'hzmat_no' = case
when SUBSTRING(miodt.vou_no, 1,1)='H'and miodt.mat_no=''then cutcurdt.mat_no
when SUBSTRING(miodt.vou_no, 1,1)='C' and miodt.mat_no='' then bultbj.mat_no else miodt.mat_no end
from miodt
left join cutcurdt on miodt.vou_no=cutcurdt.vou_no and miodt.part_no=cutcurdt.part_no
left join bultbj on miodt.vou_no=bultbj.bul_no and miodt.part_no=bultbj.part_no ) a
WHERE hzmat_no='A01010902'