任何人都可以告诉我这个查询的错误错误:ER_PARSE_ERROR:你的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的YEAR附近使用正确的语法
SELECT uw.user_id, cd.LEW, cd.event_date,dd.hwRate,d3.Wdata
FROM user_worker AS uw
LEFT JOIN _device1 AS cd ON uw.user_id = cd.uuid
WHERE YEAR(cd.event_date)=2018
LEFT JOIN _device2 AS dd ON uw.user_id = dd.uuid
WHERE YEAR(dd.event_date)=2018
LEFT JOIN _device3 AS d3 ON uw.user_id = d3.uuid
WHERE YEAR(d3.event_date)=2018
答案 0 :(得分:2)
正如评论中所说,你不能在每个联接中有多个位置,但是如果用" AND"替换所有位置,它将起作用:
SELECT uw.user_id, cd.LEW, cd.event_date,dd.hwRate,d3.Wdata
FROM user_worker AS uw
LEFT JOIN _device1 AS cd ON uw.user_id = cd.uuid
AND YEAR(cd.event_date)=2018
LEFT JOIN _device2 AS dd ON uw.user_id = dd.uuid
AND YEAR(dd.event_date)=2018
LEFT JOIN _device3 AS d3 ON uw.user_id = d3.uuid
AND YEAR(d3.event_date)=2018