如何用sql server 存储过程让这查出来的两张表变成一张

select PO.DocNO,PL.DocLineNo,ppt.Name,cim.code,pl.ItemInfo_ItemName,PL.ReqQtyRU,pl.SupplierConfirmQtyTU,pl.TotalRtnFillQtyTU,pl.OutBoxNum,pl.InBoxNum,but.Name,bc.Department,
pps.DeliveryDate,cim.ItemNature,bo.Code,ppm.PurchaseOrder from PM_PurchaseOrder PO
LEFT JOIN PM_POLine PL
ON PO.ID = PL.PurchaseOrder
left join PM_PODocType_Trl ppt
on po.DocumentType = ppt.ID
left join CBO_ItemMaster cim
on cim.ID = pl.ItemInfo_ItemID
left join Base_UOM_Trl but
on but.ID = pl.PriceUOM
left join PM_POShipLine pps
on pps.POLine = pl.ID
left join Base_Contact bc
on bc.ID = po.PurOper
left join base_Organization bo
on bo.ID = po.JDOrg
left join PM_POMemo ppm
on ppm.PurchaseOrder = po.id

select cct.Name,ee.CustomerDocNo,ee.DocNo,cim.Code from EPT_ETSO ee

left join CBO_Customer_Trl cct
on ee.Customer = cct.ID
left join EPT_ETSOLine eet
on eet.ETSO=ee.ID
left join CBO_ItemMaster cim
on eet.Item = cim.ID

sql

2个回答

方法一:外面在嵌套一层查询,将两张查询出来的表在关联起来。
方法二:可以建立临时表,将两张表数据放入临时表中。

qq_39605551
qq_39605551 回复Tastill: 多谢谢了 解决了
大约 3 年之前 回复
Tastill
Tastill 回复qq_39605551: 你把select Customer=cct.Name,CustomerDocNo=ee.CustomerDocNo,ETSO_No=ee.DocNo,Code=cim.Code from EPT_ETSO ee里查询结果的=号去掉试试,另外查看表字段属性,是否非空字段你输入了空,如果有报错日志,可以贴出来看下。
大约 3 年之前 回复
qq_39605551
qq_39605551 insert into tabase1(Customer,CustomerDocNo,ETSO_No,Code) select Customer=cct.Name,CustomerDocNo=ee.CustomerDocNo,ETSO_No=ee.DocNo,Code=cim.Code from EPT_ETSO ee left join CBO_Customer_Trl cct on ee.Customer = cct.ID left join EPT_ETSOLine eet on eet.ETSO=ee.ID left join CBO_ItemMaster cim on eet.Item = cim.ID 问一下 我这个 插入他容易报错 怎么 能让他 不抱错啊
大约 3 年之前 回复

insert into tabase1(Customer,CustomerDocNo,ETSO_No,Code) select Customer=cct.Name,CustomerDocNo=ee.CustomerDocNo,ETSO_No=ee.DocNo,Code=cim.Code from EPT_ETSO ee

left join CBO_Customer_Trl cct
on ee.Customer = cct.ID
left join EPT_ETSOLine eet
on eet.ETSO=ee.ID
left join CBO_ItemMaster cim
on eet.Item = cim.ID

问一下 我这个 插入他容易报错 怎么 能让他 不抱错啊

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐