-1

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

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'
4

3 回答 3

0

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

... consultant.user_name AS consultant_name,

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

于 2013-03-19T12:18:49.163 回答
0

删除,在 FROM 子句之前

SELECT .........consultant.user_name AS consultant_name,
FROM 
于 2013-03-19T12:22:19.053 回答
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'
于 2013-03-19T12:47:21.953 回答