我遇到以下错误
”错误号:1064
您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本以使用正确的语法 接近'1 Sum(picker_sign_out_sheet.lines_on_order)AS LINES, 在第1行的staff.staff_name AS PICKER'
我不知道从哪里开始,希望有所帮助
("SELECT TOP 1 Sum(picker_sign_out_sheet.lines_on_order) AS LINES, staff.staff_name AS PICKER
FROM picker_sign_out_sheet INNER JOIN staff ON picker_sign_out_sheet.staff_name = staff.staff_id
WHERE (((picker_sign_out_sheet.finish_date)=Date()))
GROUP BY staff.staff_name
ORDER BY Sum(picker_sign_out_sheet.lines_on_order) DESC");
我希望得到1个结果,显示哪个用户的lines_on_order总数最高。
任何帮助都是很棒的
答案 0 :(得分:0)
TOP 1
不是MySQL语法
正确的查询应该是
SELECT Sum(picker_sign_out_sheet.lines_on_order) AS LINES, staff.staff_name AS PICKER
FROM picker_sign_out_sheet INNER JOIN staff ON picker_sign_out_sheet.staff_name = staff.staff_id
WHERE (((picker_sign_out_sheet.finish_date)=Date()))
GROUP BY staff.staff_name
ORDER BY Sum(picker_sign_out_sheet.lines_on_order) DESC
LIMIT 1
答案 1 :(得分:0)
请删除顶部01并全部获得$ query-> row_array();
这只会返回一个值top