gpt4 book ai didi

mysql - 弄清楚如何使用 sql 列别名

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

我一直在尝试找出如何使用此查询执行列别名,但我似乎无法理解。

SELECT (customer.customer_id) as ID, (CUSTOMER.FIRST_NAME, CUSTOMER.LAST_NAME) as name, (customer.address,customer.town,customer.post_code) as address, LOYALTY_CARD.POINTS 
FROM LOYALTY_CARD
INNER JOIN CUSTOMER
ON LOYALTY_CARD.CUSTOMER_ID = CUSTOMER.CUSTOMER_ID WHERE LOYALTY_CARD.POINTS > 70 ORDER BY LOYALTY_CARD.POINTS

我收到的错误是操作数应包含 1 列

最佳答案

(CUSTOMER.FIRST_NAME, CUSTOMER.LAST_NAME) 作为名称 错误。如果你想组合它们,你需要连接它们。

concat(customer.first_name, ' ', customer.last_name) 作为名称

(customer.address,customer.town,customer.post_code)地址相同

concat(customer.address, ' ', customer.town, ' ', customer.post_code) 作为地址

关于mysql - 弄清楚如何使用 sql 列别名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29703766/

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