Got a small MySql problem I was hoping someone could take a look at.
Current Sql:
SELECT IFNULL(ua.total, 0) applications,
users_applications.job_id as job_id,
users.*
FROM users_applications
LEFT OUTER JOIN users
on (users_applications.user_id = users.id)
LEFT OUTER JOIN (
SELECT COUNT(*) total, job_id, id
FROM users_applications
GROUP BY job_id ) AS ua
ON (users_applications.id = ua.id)
Which is great and it’s returning something like:
applications | job_id | user_id |
-------------------------------
3 | 1001 | 1001 |
0 | 1001 | 1002 |
0 | 1001 | 1003 |
1 | 1003 | 1004 |
1 | 1003 | 1005 |
0 | 1004 | 1006 |
Although it is counting the number of applications for that job it’s only doing it for the first row, I’d like it to appear in every row instead of just a 0 for subsequent rows as it is at the moment.
Many thanks
Try this one.