gpt4 book ai didi

mysql - 如何更改 INNER JOIN 后收到的列的名称

转载 作者:行者123 更新时间:2023-11-29 15:23:09 26 4
gpt4 key购买 nike

SELECT  * FROM train 
INNER JOIN station AS s1 ON train.id_station_departure = s1.id
INNER JOIN station AS s2 ON train.id_station_arrive = s2.id

我想获取name1和name2,而不是name和name。我怎样才能做到?

最佳答案

您需要一个列名别名..但在这种情况下您可以使用 select * ..如果您需要列名别名,则必须使用显式列名

SELECT  s1.name as name1, s2.name as name2
FROM train
INNER JOIN station AS s1 ON train.id_station_departure = s1.id
INNER JOIN station AS s2 ON train.id_station_arrive = s2.id

关于mysql - 如何更改 INNER JOIN 后收到的列的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59227761/

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