1
由于将LEFT JOIN添加到下面的查询中,count(*)返回了一些奇怪的值,它似乎已将查询中返回的总行添加到'level ':添加LEFT JOIN后破碎的计数(*)
SELECT `n`.*, exp_channel_titles.*, 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`
LEFT JOIN `exp_channel_titles`
ON (`n`.`entry_id`=`exp_channel_titles`.`entry_id`),
`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`
我完全难住...谢谢!
@Iain:你可以发表'exp_node_tree_6'和'describe exp_channel_titles'的结果,并简要解释你打算做什么? – 2010-04-04 16:11:09