请教sql问题,怎样横向合并两个没有关联的表

select [ItemCode],[Dscription],[FreeTxt],[LineTotal]

from [dbo].[View_sap_OQUT] a inner join [dbo].[View_sap_QUT1] b on a.[DocEntry] = b.[DocEntry]

where [U_PM_Code] = '1-TXMUSIC08-20210802'

image.png

select [fd_wuLiaoDaiMa],[fd_385c6ec030aed4_text],[fd_ziYouWenBen],[fd_caiGouHeJia]

from [dbo].[ekp_qinggoudan] a inner join [dbo].[ekp_qinggoudan1] b on a.fd_id = b.fd_parent_id

inner join [dbo].[km_review_main] krm on krm.fd_id = a.fd_id

where [fd_guiShuXiangMuHao] = '1-TXMUSIC08-20210802' and [doc_status] = '30'

image.png

想让这两个结果横向合并

用户m2896739 发布于 2021-8-26 15:37 (编辑于 2021-8-26 16:35)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
梦想的初衷Lv7初级互助
发布于2021-8-26 15:49
SELECT * FROM( SELECT [ ItemCode ],[ Dscription ],[ FreeTxt ],[ LineTotal ] ,1 as fz FROM [ dbo ].[ View_sap_OQUT ] a INNER JOIN [ dbo ].[ View_sap_QUT1 ] b ON a.[ DocEntry ] = b.[ DocEntry ] WHERE [ U_PM_Code ] = '1-TXMUSIC08-20210802')a LEFT JOIN( select [fd_wuLiaoDaiMa],[fd_385c6ec030aed4_text],[fd_ziYouWenBen],[fd_caiGouHeJia],1 as fz from [dbo].[ekp_qinggoudan] a inner join [dbo].[ekp_qinggoudan1] b on a.fd_id = b.fd_parent_id inner join [dbo].[km_review_main] krm on krm.fd_id = a.fd_id where [fd_guiShuXiangMuHao] = '1-TXMUSIC08-20210802' and [doc_status] = '30' )b ON a.fz=b.fz
  • 用户m2896739 用户m2896739(提问者) 感谢,fz这个字段改成序号就可以了,都是1的话,会join好几遍
    2021-08-26 17:35 
  • 2关注人数
  • 660浏览人数
  • 最后回答于:2021-8-26 16:35
    请选择关闭问题的原因
    确定 取消
    返回顶部