这两个Sql,如何将第二个Sql查询的列加在第一个查询结果集中?即 Param_Value2加在Param_Value1列的右边。注意,第一sql查询结果集是51行,整个结果集需保持51行,只是增加列SELECT t_Param_List.Deivce_ID ,t_Device_List.Deivce_Name_CN ,t_Param_Define.Param_ID ,Param_Name_EN ,Param_Name_CN ,Unit ,Param_Value AS Param_Value1FROM t_Param_DefineLEFT JOIN t_Param_List ON t_Param_List.Param_ID = t_Param_Define.Param_IDLEFT JOIN dbo.t_Device_List ON t_Device_List.Device_ID = t_Param_List.Deivce_IDWHERE Deivce_ID = 'F216FB17B6F8FB874D43E0434BCAC0F1'ORDER BY t_Param_Define.Param_ID ASC SELECT Param_Value AS Param_Value2FROM t_Param_ListWHERE Deivce_ID = '98503477C170CD6234DAF04EDBB954CB'
1 回答
湖上湖
TA贡献2003条经验 获得超2个赞
SELECT t_Param_List.Deivce_ID ,
t_Device_List.Deivce_Name_CN ,
t_Param_Define.Param_ID ,
Param_Name_EN ,
Param_Name_CN ,
Unit ,
Param_Value AS Param_Value1,
a.Param_Value AS Param_Value2
FROM t_Param_Define
LEFT JOIN t_Param_List ON t_Param_List.Param_ID = t_Param_Define.Param_ID
LEFT JOIN dbo.t_Device_List ON t_Device_List.Device_ID = t_Param_List.Deivce_ID
outer apply t_Param_List a
WHERE Deivce_ID = 'F216FB17B6F8FB874D43E0434BCAC0F1'
and
a.Deivce_ID = '98503477C170CD6234DAF04EDBB954CB'
ORDER BY t_Param_Define.Param_ID ASC
- 1 回答
- 0 关注
- 1310 浏览
添加回答
举报
0/150
提交
取消