我有两个表per_asg
和xx_asg
,它们有相同的no。列,理想情况下应该有相同的号码。数据的。查询两个表的Start_date在sql中不匹配
per_asg:
person_id start_date end_date
-------------------------------------------
1 01-jan-2016 07-jan-2016
1 02-feb-2016 08-march-2016
xx_per_asg
person_id start_date end_date
-------------------------------------
1 01-jan-2016 07-jan-2016
1 02-feb-2016 08-march-2016
1 03-feb-2016 04-sep-2016
由于看到xx_per_asg有一个额外的行与起始日期'03-feb-2016'
日期和结束日期'04-sep-2016'.
我写了一个查询来获取这样的行,但我我没有完全得到额外的行:
select start_date
from xx_per_asg xx_per_asg, per_asg pa
where xx_per_asg.person_id = pa.person_id
and xx_per_asg.start_date <> pa.start_date
但是,这仍然会数据
[不良习惯踢:使用旧式JOIN](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old -style-joins.aspx) - 在ANSI - ** 92 ** SQL标准中,旧式*逗号分隔的表*样式列表已替换为* proper * ANSI'JOIN'语法(**超过20年**前),其使用是不鼓励 –