本文介绍了左外部联接不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我在下表中有-
tr_resource作为res-
tr_resource as res -
Resourceid name
135021 ABC
tr_charac为chlev-
tr_charac as chlev -
characid name
1 CH1
2 CH2
tr_characvalue作为cvlev-
tr_characvalue as cvlev -
characvalueid characid stringvalue
cv1 1 XX
cv2 2 YY
cv3 2 zz
tr_resourcecharac作为rchlev-
tr_resourcecharac as rchlev -
resourceid characvalueid
135021 cv2
当我在查询下面运行时-
When i run below query -
select
res.name,
cvlev.stringvalue
from tr_resource res
left outer join tr_resourcecharac rchlev on res.RESOURCEID = rchlev.RESOURCEID
inner join tr_characvalue cvlev on rchlev.CHARACVALUEID = cvlev.CHARACVALUEID
inner join tr_charac chlev on chlev.CHARACID = cvlev.CHARACID and chlev.NAME = 'CH2'
where res.resourceid=135021
我得到的答案是-
name stringvalue
ABC YY
但是当我在查询下面运行时,我没有得到任何答案-
but when i run below query, i am not getting any answer -
select
res.name,
cvlev.stringvalue
from tr_resource res
left outer join tr_resourcecharac rchlev on res.RESOURCEID = rchlev.RESOURCEID
inner join tr_characvalue cvlev on rchlev.CHARACVALUEID = cvlev.CHARACVALUEID
inner join tr_charac chlev on chlev.CHARACID = cvlev.CHARACID and chlev.NAME = 'CH1'
where res.resourceid=135021
我想以-
name stringvalue
ABC null
能请你帮忙吗?
推荐答案
您必须将所有内部联接更改为左侧外部联接.
You have to change all the inner joins to left outer joins.
这篇关于左外部联接不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!