对此查询引入联接,可能吗?
我试图向此查询引入联接:
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`
添加
LEFT JOIN `exp_channel_titles`
ON (`n`.`entry_id`=`exp_channel_titles`.`entry_id`)
通过在 FROM 语句之后
...但是当我引入它时,它失败并显示“'on 子句'中的未知列'n.entry_id'”
是否可以添加对此查询的联接?
有谁可以帮忙吗,谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想您的问题来自于您在表列表末尾添加了 join 子句。尝试
您只能在 ON 子句中引用属于 JOIN 流中已存在的表的字段。
我希望这对你有帮助
杰罗姆·瓦格纳
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