I have the following subqueries, and they are throwing an error
select ts.id,(CONCAT(ts.first_name, ' ', ts.last_name),
( select SUM(hours*pay)
from
PTAddedApp aa
where
aa.tutor_id = ts.id
and year(aa.date) = year(now())
and month(aa.date) = month(now())
),
(select SUM(nt.hours*nt.rate)
from PT_NT_Work_Hours nt
where
nt.tutor_id = ts.id
and year(nt.date) = year(now())
and month(nt.date) = month(now())
)
from PT_Tutors ts
I get the following error message. I assume that I am doing something daft-
1064 – 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 ‘from PT_Tutors ts’ at line 21
I posted a similar questions to see if I should use joins instead, and they pointed me back to subqueries, so I’m hoping someone can let me know what I am doing wrong.
You open 2 brackets near your concat function but only close 1. Remove the bracket before ‘CONCAT’