gpt4 book ai didi

mysql - 使用 SQL select 时如何处理列中的空格

转载 作者:行者123 更新时间:2023-11-29 10:53:58 24 4
gpt4 key购买 nike

我的数据库表中有 3 列。 Id 运营商,o.Id 国家/地区

select [o.Id Operator] as OperatorID,[o.Id Country] as countryid
from
customersubscription cs inner join club cl on (cs.idclub = cl.idclub)
inner join customer cu on (cs.idcustomer = cu.idcustomer)
inner join operator o on (cu.idoperator = o.idoperator)
left outer join promoter p on (cs.idpromoter = p.id )
where
cl.idproject in (3,19,23,24,27)

所选部分中的两列中有空格。我使用了 [ ] 并按照问题 here 中提到的方式进行了尝试但没有成功。

最佳答案

在 MySQL 中,任何不简单的列名(由字母、数字和/或下划线组成)都必须转义:

SELECT o.`Id Operator` as OperatorID,
o.`Id Country` as countryid

如果您调用第一个 OperatorID,为了保持一致性,下一个应该是 CountryID

关于mysql - 使用 SQL select 时如何处理列中的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43303604/

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