【发布时间】:2018-08-06 17:53:09
【问题描述】:
数据库中有users、organization_entries和user_invoices三个表,我正在尝试加入这三个表,我的查询有点像这样
select users.id , sum(user_invoices.due_amount) , organization_entries.id, organization_entries.createdAt from users INNER JOIN user_invoices ON users.id = user_invoices.customer_id INNER JOIN on users.id = organization_entries.user_id GROUP BY users.id ORDER BY organization_entries.createdAt;
但一次又一次,我得到这个错误 -
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on users.id = organization_entries.user_id GROUP BY users.id ORDER BY organiza' at line 1
我无法理解我做错了什么。
【问题讨论】:
-
INNER JOIN on users.id = organization_entries.user_id处缺少表名 -
是的,愚蠢的错误,非常感谢
标签: mysql database join group-by sql-order-by