gpt4 book ai didi

mysql - 'LEFT JOIN' 附近的错误 1064

转载 作者:行者123 更新时间:2023-11-29 06:22:04 28 4
gpt4 key购买 nike

我创建了两个临时表并使用以下代码将它们连接在一起,但在“LEFT JOIN”附近遇到了 ERROR 1064

(SELECT DISTINCT routes.route_short_name, MIN(stop_times.stop_sequence) AS first_stop, stops.stop_name AS first_stop_name
FROM trips
JOIN routes ON ...
JOIN stop_times ON ...
JOIN stops ON ...
JOIN calendar ON ...
GROUP BY stop_times.trip_id) first_table
LEFT JOIN
(SELECT DISTINCT routes.route_short_name, MAX(stop_times.stop_sequence) AS last_stop, stops.stop_name AS last_stop_name
FROM trips
JOIN routes ON ...
JOIN stop_times ON ...
JOIN stops ON ...
JOIN calendar ON ...
GROUP BY stop_times.trip_id) last_table
ON first_table.route_short_name = last_table.route_short_name;

想要的结果是这样的:

route_short_name, first_stop_name, last_stop_name
...

最佳答案

您没有错过实际的主要选择语句吗?

SELECT route_short_name, first_stop_name, last_stop_name FROM   --this part is missing
(SELECT DISTINCT ...) first_table
LEFT JOIN
(SELECT DISTINCT ...) last_table
ON first_table.route_short_name = last_table.route_short_name;

关于mysql - 'LEFT JOIN' 附近的错误 1064,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32869610/

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