gpt4 book ai didi

mysql - #1064 - 创建 View 时 SQL 语法有错误

转载 作者:行者123 更新时间:2023-11-29 13:54:05 24 4
gpt4 key购买 nike

这段代码有什么问题导致它返回错误?

我的代码如下:

CREATE OR REPLACE VIEW vw_training AS 
SELECT training.train_attended, clients.client_firstname, clients.client_lastname, clients.client_swn, clients.client_id, locations.loc_id, locations.loc_title, locationsp.loc_id, locationsp.loc_title,
FROM training
JOIN clients ON clients.client_id = training.train_clientid
JOIN locations AS locationsp ON locations.loc_id = training.train_pickup
LEFT JOIN locations ON locations.loc_id = clients.client_winz

这是我返回的错误:

#1064 - You have an error in your SQL syntax; check the manual thatcorresponds to your MySQL server version for the right syntax to usenear 'FROM training JOIN clients ON clients.client_id =training.train_clientid JOIN' at line 3

我正在运行 phpMyAdmin 版本 3.5.2.2。

我之前使用过具有不同值的此脚本,没有出现任何问题。

最佳答案

FROM 子句之前有一个额外的尾随逗号

SELECT ....,
locationsp.loc_id,
locationsp.loc_title, -- <<== remove this trailing comma
FROM training ...

另一个错误会引发此消息:“on Clause”中的未知列“locations.loc_id”是使用表名而不是提供的别名。应该是这样的,

JOIN locations AS locationsp ON locationsp.loc_id = training.train_pickup
^^ should use alias here

关于mysql - #1064 - 创建 View 时 SQL 语法有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16159596/

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