【发布时间】:2010-04-04 15:29:22
【问题描述】:
自从将LEFT JOIN添加到下面的查询中,count(*)一直返回一些奇怪的值,似乎将查询中返回的总行数添加到'level':
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:能否请您发布
describe exp_node_tree_6和describe exp_channel_titles的结果并简要说明您打算做什么?