我可能在这里遗漏了一些明显的东西。我有一个 WordPress 分类法,它parent
通过wp_term_taxonomy
. 我正在尝试编写一个查询,该查询将返回一行,无论是否存在子区域(仍返回县)。在此示例中,我正在查询我知道数据库中存在的区域 ('PHILADELPHIA') 以及我知道不存在的子区域 ('asdfasdfasdf')。如果我将“asdfasdfasdf”更改为我知道存在的子区域,则该行返回正常,但如果该子区域不存在,我不会在 RIGHT 表中得到 NULL(没有行返回,就好像它在做一个内部连接)。这是查询:
SELECT region_wtt.term_taxonomy_id AS region_ttid,
region_wtt.term_id AS region_tid,
region_wt.name AS region_name,
subregion_wtt.term_taxonomy_id AS subregion_ttid,
subregion_wtt.term_id AS subregion_tid,
subregion_wt.name AS subregion_name
FROM wp_term_taxonomy region_wtt
RIGHT OUTER JOIN wp_term_taxonomy subregion_wtt
ON region_wtt.term_taxonomy_id = subregion_wtt.parent
RIGHT OUTER JOIN wp_terms region_wt
ON region_wtt.term_id = region_wt.term_id
RIGHT OUTER JOIN wp_terms subregion_wt
ON subregion_wtt.term_id = subregion_wt.term_id
WHERE region_wtt.taxonomy='tsml_region'
AND region_wtt.parent = 0
AND region_wt.name='PHILADELPHIA'
AND subregion_wtt.taxonomy='tsml_region'
AND subregion_wt.name='asdfasdfasdf';
我错过了什么?