INNER join question

Hi Guys!

I have the following join query but it’s throwing the error below. I think it’s because there’s not always rows in the ‘cv_alert_industries’ and ‘cv_alert_job_types’ tables. Am I using the wrong type of join?


SELECT cv_alerts . * , i.industry, j.job_type
FROM cv_alerts
INNER JOIN (

SELECT alert_id, group_concat( industry_id
SEPARATOR ',' ) AS industry
FROM cv_alert_industries
) AS i ON i.alert_id = cv_alerts.id
INNER JOIN (

SELECT alert_id, group_concat( job_type_id
SEPARATOR ',' ) AS job_type
FROM cv_alert_job_types
) AS j ON j.alert_id = cv_alerts.id
WHERE cv_alerts.id = '1'
AND cv_alerts.company_id = '1001'
LIMIT 1


Error:

#1048 - Column 'alert_id' cannot be null

Thanks in advance.

I think you are missing a GROUP BY in your subselects ?