两个SQL语法错误选择join

时间:2014-06-29 08:36:35

标签: mysql sql

我尝试与另一个选择进行左连接,但我一直收到语法错误:

  

您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,以便使用接近' LEFT JOIN的正确语法(选择prediction_id,费用的总和(值)作为valoarea GROUP BY p'在第3行

SELECT id, name FROM `predictions` 
where `predictions` .tablet_id in (select id from tablets where user_id = 19)
LEFT JOIN (SELECT prediction_id, sum(value) from expenses as expense_value GROUP BY prediction_id) ex
ON `predictions`.id = `ex`.prediction_id;
有人看到有什么不对吗?谢谢!

1 个答案:

答案 0 :(得分:3)

JOIN

之前看syntax of a SELECT queryWHERE
SELECT id, name FROM `predictions` 
LEFT JOIN (SELECT prediction_id, sum(value) from expenses as expense_value GROUP BY prediction_id) ex
ON `predictions`.id = `ex`.prediction_id;
where `predictions`.tablet_id in (select id from tablets where user_id = 19)