2个SQL命令如何合一?
TEXT TO m.all_SQLCmd_FP NOSHOW TEXTMERGE
select A.*,W.*,W.goodsid as Dvendorid FROM produce_bom A
LEFT JOIN produce_bom_dtl W ON A.bom_id=W.bom_id
where A.goodsid in (下面一段命令,运行后,得到的表,表名为all_danju_FP1.goodsid) and ( W.weight_2 <>0 or W.weight_3 <> 0 )
ENDTEXT
SQLEXEC(nhandle,m.all_SQLCmd_FP,"all_danju_FP")
这是第二段命令
TEXT TO m.all_SQLCmd_FP NOSHOW TEXTMERGE
select AA.*,WW.*,
WW.goodsid as Dvendorid
FROM produce_bom AA
LEFT JOIN produce_bom_dtl WW ON AA.bom_id=WW.bom_id
where AA.goodsid = <<m.dI_3F>> and WW.Goodsid in (select goodsid from ba_goods where goodsclsid = 200)
ENDTEXT
SQLEXEC(nhandle,m.all_SQLCmd_FP,"all_danju_FP1")
不知道这二段命令,如何合并?
[解决办法]
select A.*,W.*,W.goodsid as Dvendorid FROM produce_bom A
LEFT JOIN produce_bom_dtl W ON A.bom_id=W.bom_id
where A.goodsid in (
select WW.goodsid
FROM produce_bom AA
LEFT JOIN produce_bom_dtl WW ON AA.bom_id=WW.bom_id
where AA.goodsid = <<m.dI_3F>> and WW.Goodsid in (select goodsid from ba_goods where goodsclsid = 200))
and ( W.weight_2 <>0 or W.weight_3 <> 0 )