Closed. This question is off-topic。它目前不接受答案。
想改进这个问题吗?Update the question所以堆栈溢出的值小于aa>。
四年前关闭。
我好像没法让这个工作。我有两个表要连接,但其中一个列在几个标题中有一个空格。我正在尝试以下代码,但没有成功。
我还没有从join中购买列,因为我想测试我是否可以进行join。
SELECT rcm.activitydatetime, rcm.'lead id', rcm.'new stage'
FROM customername_leads_by_lifecycle_stage_rcm AS rcm
INNER JOIN customername_leads AS leads
ON rcm.'lead id' = leads.ID;

我得到的警告是
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 ''lead id', rcm.'new stage' FROM customername_leads_by_lifecycle_stage_rcm AS rcm INNE' at line 1

任何帮助都是值得感谢的,谢谢!

最佳答案

对列名使用反勾号(`),而不是单引号(')

SELECT rcm.activitydatetime, rcm.`lead id`, rcm.`new stage`
FROM customername_leads_by_lifecycle_stage_rcm AS rcm
INNER JOIN customername_leads AS leads
ON rcm.`lead id` = leads.ID;

您还可以考虑重命名列,使它们没有空格。

10-06 09:43