could you try this?
SELECT node.*, category_info.name, (COUNT(parent.url) - 1) AS depth
FROM categories AS node INNER JOIN
^^^^^^^^^^^ <= this is added
categories AS parent
JOIN category_info ON node.id = category_info.category_id
WHERE node.lft BETWEEN parent.lft AND parent.rgt AND category_info.lang_id = 1
GROUP BY node.url
ORDER BY node.lft
When JOIN
is missing, the column can not be referenced in ON
clause, but can be reference in WHERE
part
Here is what I have tried.
mysql> SELECT * FROM t1 tab1 INNER JOIN t1 tab2 INNER JOIN t2 tab3 ON tab1.a = tab3.a;
Empty set (0.00 sec)
mysql> SELECT * FROM t1 tab1, t1 tab2 INNER JOIN t2 tab3 ON tab1.a = tab3.a;
ERROR 1054 (42S22): Unknown column 'tab1.a' in 'on clause