新手问题,请问这两条SQL语句怎么整合到一起?
select shopprodItemName,shopprodItemID from [QBS_shopProdItem] where shopID=1022
select shopName from [QBS_Shop] where shopID=1022
------解决方案--------------------這樣?
select shopprodItemName,shopprodItemID from [QBS_shopProdItem] where shopID=1022
Union All
select shopName, Null from [QBS_Shop] where shopID=1022
------解决方案--------------------整合是指什么?
------解决方案--------------------select a.shopprodItemName,a.shopprodItemID,b.shopName from [QBS_shopProdItem] a, [QBS_Shop] b where a.shopID=1022 and a.a.shopID=b.a.shopID
------解决方案--------------------明白了,是join啊
------解决方案--------------------select shopprodItemName,shopprodItemID from [QBS_shopProdItem] where shopID=1022
union all
select shopName shopprodItemName , shopprodItemID = 0 from [QBS_Shop] where shopID=1022
------解决方案--------------------以后问问题说出所要得到的结果
------解决方案--------------------select shopprodItemName,shopprodItemID from [QBS_shopProdItem] where shopID=1022
Union All
select shopName, Null from [QBS_Shop] where shopID=1022
--或者是
select A.shopprodItemName, A.shopprodItemID, B.shopName from [QBS_shopProdItem] A Inner Join [QBS_Shop] B
On A.shopID = B.shopID
where A.shopID=1022