首页 > 数据库技术 > 详细

SQL语句将两个select语句查询结果合并一个

时间:2021-04-18 21:47:02      阅读:32      评论:0      收藏:0      [点我收藏+]

1. SQL语句将两个select语句查询结果合并一个

用到"FULL JOIN"关键字语法

 

1    SELECT TOP 1 * FROM T_CONNSTATUSLOG WHERE PROBERID=TELC01 ORDER BY ID DESC
2    SELECT TOP 1 * FROM T_PRODUCTLOG WHERE PROBERID=TELC01 ORDER BY ID DESC
3      
4  select isnull(a.PROBERID,b.PROBERID) PROBERID, ISNULL(a.ID,0) aID,ISNULL(a.INSERTTIME,0) INSERTTIME,isnull(a.CONNSTATUS,0) CONNSTATUS,ISNULL(b.ID,0) bID ,isnull(b.PROBERCARDID,0) PROBERCARDID,isnull(b.READTIME,0) READTIME
5  from (SELECT TOP 1 * FROM T_CONNSTATUSLOG WHERE PROBERID=TELC01 ORDER BY ID DESC) A 
6  FULL JOIN (SELECT TOP 1 * FROM T_PRODUCTLOG WHERE PROBERID=TELC01 ORDER BY ID DESC) b on a.PROBERID=b.PROBERID

 

SQL语句将两个select语句查询结果合并一个

原文:https://www.cnblogs.com/RookieJ/p/14537604.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!