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

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

 

上一篇:从"UDF不应有状态" 切入来剖析Flink SQL代码生成


下一篇:170103、Redis官方集群方案 Redis Cluster