gpt4 book ai didi

mysql - 使用保留名称作为列名

转载 作者:行者123 更新时间:2023-11-29 05:39:39 27 4
gpt4 key购买 nike

我正在尝试运行此查询但没有运行

SELECT ng.parent_id, ng.tab, ng.post_id, ng.ORDER, ng.cluster_key, pd.id, pd.slug, pd.link_text, pd.parent
FROM `ecom_navigation` AS ng, `ecom_page_data` AS pd
WHERE ng.cluster_key = 'primary'
AND ng.tab = '0'
AND ng.parent_id = '1'pd.id = ng.post_id
ORDER BY ng.order

出现错误

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'pd.id = ng.post_id ORDER BY ng.order' at line 1

我已经尝试过 `ng.order` 和 `ng`.`order` 但似乎仍然无法运行。

非常感谢任何帮助

最佳答案

我认为您只是缺少一个:

AND ng.parent_id = '1'pd.id = ng.post_id

应该是:

AND ng.parent_id = '1'
AND pd.id = ng.post_id

或者更好的是,将连接条件放在连接中(并且不要引用您的数字,除非它们确实是字符串):

SELECT ng.parent_id, ng.tab, ng.post_id, ng.ORDER, ng.cluster_key, pd.id, pd.slug, pd.link_text, pd.parent
FROM `ecom_navigation` AS ng join `ecom_page_data` AS pd on ng.post_id = pd.id
WHERE ng.cluster_key = 'primary'
AND ng.tab = 0 -- Leave the quotes on if tab is a string
AND ng.parent_id = 1 -- Leave the quotes on if parent_id is a string
ORDER BY ng.order

关于mysql - 使用保留名称作为列名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7789262/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com