有人可以告诉我这段代码有什么问题让它吐回错误吗?
我的代码如下:
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
- 您的SQL语法出错;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 靠近'FROM training JOIN clients ON clients.client_id = training.train_clientid在第3行加入
我正在运行phpmyadmin版本信息:3.5.2.2
我之前使用过不同值的此脚本
答案 0 :(得分:1)
在FROM
子句
SELECT ....,
locationsp.loc_id,
locationsp.loc_title, -- <<== remove this trailing comma
FROM training ...
以及引发此消息的另一个错误:Unknown column 'locations.loc_id' in 'on clause'
是使用tablename
而不是提供的别名。它应该是,
JOIN locations AS locationsp ON locationsp.loc_id = training.train_pickup
^^ should use alias here