This topic is locked

Error message in SQL Syntax

9/7/2016 2:15:53 PM
PHPRunner General questions
J
jasongreenwood author

I've run into trouble when writing a query to retrieve data from 3 tables as below the error message comes up when clicking on the add page..
"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'left join ( select company, count(counting) as count from child group b' at line 4"
SELECT

brigade_id.company_name, a.count, b.leaders

from brigade_id

left join (

select company, count(counting) as count

from child

group by company

) a on brigade_id.company_name=a.company

left join(

select company, count(counting) as leaders

from leader1

group by company

) b on brigade_id.company_name=b.company
I've tried various ways but I still get the same error message?
Would anyone be able to assist please?
Thank you.

Sergey Kornilov admin 9/8/2016

Hard to tell what might be wrong without actually running the code and seeing where it breaks.
More interesting question is how do you build an Add page for this. This a multi-table query with joins and group by, not clear what table you going to add your data to.