2013-03-19 90 views
0

查询1:比较查询输出

select name,trans from sids s where apt='KAUS'; 

查询2:名称的

SELECT id,transition_id from std_sid_leg where data_supplier='E' and airport='KAUS'; 

值是相同该ID的和反式与transition_id.Result集1是结果集2.Both的子集这些表的公共列为apt = airport 如果查询本身无法工作,请提供任何脚本。 我需要比较这两个查询的输出并打印数据差异。 谢谢。

+0

是一门功课?你来这里是为了什么? – 2013-03-19 11:39:35

回答

0

您正在寻找组合的左+右连接。
这被称为完全外连接(而不是左外/右外连接)。
通过只选择连接列为空的行,您将得到不匹配;这被称为反连接。

完全外部抗加入这个样子的:

select s.*, ssl.* 
from sids s 
outer join std_sid_leg ssl on (s.name = ssl.id and s.trans = ssl.transition_id) 
where (s.name is null and s.trans is null) 
    or (ssl.id is null and ssl.transition_id is null) 
+0

嘿约翰我不能得到你所说的...你可以请详细解释。谢谢 – user2037445 2013-03-19 12:14:20

+0

我真正要求的是..我有2个查询是在2个不同的表具有不同的架构执行..输出这些查询需要进行比较,并显示差异。它与结果集的比较有点类似,但问题是查询是基于某些条件检索的,而且对于检索的结果集,模式不同。 – user2037445 2013-03-19 12:17:50

+0

结果1: 'ACT','ACT'; 'AUS3','ABI'; 'AUS3','AGJ'; 'AUS3','JCT'; 结果2: 'ACT','ACT'; 'AUS3','ABI'; 'AUS3','AGJ'; OUTPUT: 'AUS3','JCT'; – user2037445 2013-03-19 12:20:27