外连接2个表并保留相同的值

时间:2014-11-18 04:10:22

标签: mysql

我有以下2个表格,我想以这样的方式使用联接,它应该显示cname,sname,year,sex,rname,incidencecount和mortalitycount,其中cname,sname,year,sex和rname来自incidenttest = cname,sname ,年,性和rname。当这些不匹配时,如果它来自事件测试,它仍应显示cname,sname,year,sex,rname,incidencecount和deathcount为(null);如果它来自死亡率测试,它应该显示cname,sname,year,sex,rname,incidencecount为(null)和deathcount。

table structre for incidenttest and mortalitytest table

This is how I executed but the problem is with the where clause; i want to use some join which will show the null values in incidentcount when records are only coming from mortality table and vice versa. I hope my doubt is clear to understand.

这是我执行的方式,但问题在于where子句;我想使用一些连接,当记录只来自死亡率表时,它会在incidentcount中显示空值,反之亦然。我希望我的疑问很清楚。

0 个答案:

没有答案