I’m trying to introduce a join to this query:
SELECT `n`.*, round((`n`.`rgt` - `n`.`lft` - 1) / 2, 0) AS childs,
count(*) - 1 + (`n`.`lft` > 1) + 1 AS level,
((min(`p`.`rgt`) - `n`.`rgt` - (`n`.`lft` > 1)) / 2) > 0 AS lower,
(((`n`.`lft` - max(`p`.`lft`) > 1))) AS upper
FROM `exp_node_tree_6` `n`, `exp_node_tree_6` `p`, `exp_node_tree_6`
WHERE `n`.`lft`
BETWEEN `p`.`lft`
AND `p`.`rgt`
AND ( `p`.`node_id` != `n`.`node_id` OR `n`.`lft` = 1 )
GROUP BY `n`.`node_id`
ORDER BY `n`.`lft`
by adding
LEFT JOIN `exp_channel_titles`
ON (`n`.`entry_id`=`exp_channel_titles`.`entry_id`)
after the FROM statement…
But when I introduce it, it fails with “Unknown column ‘n.entry_id’ in ‘on clause'”
Is it even possible to add a join to this query?
Can anybody help, thanks!
I suppose your problem comes from the fact that you add the join clause at the end of the table list. Try
You can only reference in an ON clause fields that belong to tables that are already in the JOIN stream.
I hope this will help you,
Jerome Wagner