MySQL Query中出现#1064错误

时间:2013-03-19 12:16:05

标签: mysql sql

我在执行下面的查询时遇到错误,但我无法找出问题所在。有人可以帮忙吗?

SELECT shifts.consultant_uid AS consultant_uid, shifts.status AS 
status , shifts.pay_roll_no AS pay_roll_no, shifts.week_ending AS week_ending, shifts.shifts_date AS shifts_date, shifts.description AS description, shifts.units AS units, shifts.pay_rate AS pay_rate, shifts.charge_rate AS charge_rate, shifts.pay_amount AS pay_amount, shifts.charge_amount AS charge_amount, shifts.margin_amount AS margin_amount, shifts.client_name AS client_name, consultant.user_name AS consultant_name, 

FROM a_shifts AS shifts

LEFT JOIN a_users AS consultant ON shifts.consultant_uid = consultant.user_uid
WHERE 1 

AND week_ending >=  '2013-03-17'
AND week_ending <=  '2013-03-24'

3 个答案:

答案 0 :(得分:0)

SELECT子句中字段列表的末尾有一个额外的逗号:

... consultant.user_name AS consultant_name,

作为一般建议,通常实际错误表示查询中遇到错误的位置。在大多数情况下,它指示的位置就在问题之后,因为这是查询遇到的第一个无法解析的问题(在这种情况下,FROM关键字)错误。

答案 1 :(得分:0)

在FROM子句

之前删除
SELECT .........consultant.user_name AS consultant_name,
FROM 

答案 2 :(得分:0)

试试这个

SELECT shifts.consultant_uid AS consultant_uid, shifts.status AS 
status , shifts.pay_roll_no AS pay_roll_no, shifts.week_ending AS week_ending, shifts.shifts_date AS shifts_date, shifts.description AS description, shifts.units AS units, shifts.pay_rate AS pay_rate, shifts.charge_rate AS charge_rate, shifts.pay_amount AS pay_amount, shifts.charge_amount AS charge_amount, shifts.margin_amount AS margin_amount, shifts.client_name AS client_name, consultant.user_name AS consultant_name

FROM a_shifts AS shifts

LEFT JOIN a_users AS consultant ON shifts.consultant_uid = consultant.user_uid
WHERE 1 

AND week_ending >=  '2013-03-17'
AND week_ending <=  '2013-03-24'