I am pulling all of the information for solutions using cross referenced tables.
SELECT
s.*, u.forname, u.surname, u.email, u.tel, p.type
FROM _user_solution s
INNER JOIN _users u
ON s.uid = u.uid
INNER JOIN _payment_plans p
ON p.pid = s.payment_plan_type
Which works fine and my results are as expected. However, I have another table which holds tasks for that solution, each task has a progress. I want to bring out how many tasks that solution has, I have tried:
SELECT
s.*, u.forname, u.surname, u.email, u.tel, p.type,
(SELECT COUNT(*) FROM t WHERE t.progress < 100 AS task)
FROM _user_solution s
INNER JOIN _users u
ON s.uid = u.uid
INNER JOIN _payment_plans p
ON p.pid = s.payment_plan_type
INNER JOIN _solution_tasks t
ON s.sid = t.assigned_for_solution
But I am getting this error:
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 'AS task) FROM _user_solution s INNER JOIN _users u ON s.uid = u.uid' at line 3
Any ideas on how I can count all of the tasks that are incomplete to this solution would be much appreciated.