考虑以下代码:
select (some columns)
from efdan_setup a,crit_efdan_val b,efdan c
where a.dan *= c.code
and b.codef *= c.codef
and b.mhnmis *= c.mhnmis
and b.etmis *= c.etmis
and b.ebdmis *= c.ebdmis
and b.mhnet *= c.mhnet
and b.mhnet_plir *= c.mhnet_plir
我对老式的联接不是很熟悉,并且我已经读了很多书,以了解我可能应该对此进行更改。我不知道哪个是新风格。我的猜测:
from
crit_efdan_val b
left join efdan c on
b.codef = c.codef
and b.mhnmis = c.mhnmis
and b.etmis = c.etmis
and b.ebdmis = c.ebdmis
and b.mhnet = c.mhnet
and b.mhnet_plir = c.mhnet_plir
right join fdan_setup a on a.dan = c.code
答案 0 :(得分:3)
您几乎在那里-但是混合左连接和右连接几乎与混合物质和反物质一样糟糕。
实际上,有些人(包括我自己)宁愿完全避免右联接,而只坚持左联接。
这是我的写法:
from efdan_setup a
left join efdan c
on a.dan = c.code
left crit_efdan_val b
on b.codef = c.codef
and b.mhnmis = c.mhnmis
and b.etmis = c.etmis
and b.ebdmis = c.ebdmis
and b.mhnet = c.mhnet
and b.mhnet_plir = c.mhnet_plir