Reputation: 12025
There is an trivial SQL query:
SELECT enterprise_invoces.AC_name,
enterprise_invoces.AC_id,
enterprise_invoces.AC_code,
ABS(SUM(IF(AT_amount>0, AT_amount, 0)) AS debit,
ABS(SUM(IF(AT_amount <0, AT_amount, 0)) AS credit
FROM account_transactions
INNER JOIN enterprise_invoces ON enterprise_invoces.AC_id = account_transactions.AT_code
I get this error message:
> # 1064 - You have an error in the request. Check the MySQL version documentation for correct syntax near 'FROM account_transactions INNER
> JOIN enterprise_invoces ON enterprise_invoces.AC' on line 1
Upvotes: 1
Views: 44
Reputation: 176214
You need to close brackets:
SELECT enterprise_invoces.AC_name,
enterprise_invoces.AC_id,
enterprise_invoces.AC_code,
ABS(SUM(IF(AT_amount>0, AT_amount, 0))) AS debit, --here
ABS(SUM(IF(AT_amount <0, AT_amount, 0))) AS credit -- here
FROM account_transactions
JOIN enterprise_invoces
ON enterprise_invoces.AC_id = account_transactions.AT_code
GROUP BY enterprise_invoces.AC_name,
enterprise_invoces.AC_id,
enterprise_invoces.AC_code -- there should be corresponding `GROUP BY`
Upvotes: 4