0
我有以下查询,其中列出了与其相关的类别和父类别。MYSQL获取主要类别
t.term_id is the category ID
tx.parent is the ID of category from which they depend from.
Main Categories have parent id= 0
而这是问题,因为查询不显示主要类别,但只是子类别。基本上它只显示父> 0的记录,但我需要父=> 0。我已经把它放在哪里,但它不起作用。
SELECT t.term_id, t.name, tx.parent, tm.name
from mg_terms t
join mg_term_taxonomy tx
on tx.term_id = t.term_id
join mg_terms tm
on tm.term_id = tx.parent
where tx.taxonomy='product_cat'
ORDER BY `tx`.`parent` DESC
任何帮助获得主要类别(父= 0)以及?
嗯,如果我理解正确的话,你需要的是'LEFT JOIN mg_terms tm',而不是'JOIN mg_terms tm' – sagi
哦,最有可能的。我很快来到 – Alex