I want to do a SELECT that gets the data from a table and also JOINS the information from a table where the d.demographic_category_id from demographic_data doesn't exist in demographic_category column c.demographic_category_id
So it's something like this:
SELECT *
FROM demographic_data d
INNER JOIN demographic_info i
ON d.demographic_info_id = i.demographic_info_id
AND i.student_id = 1
LEFT JOIN demographic_category c
ON d.demographic_category_id
NOT IN ( select c.demographic_category_id from demographic_category c);
What i want to do is to get the demographic_data which is being done correctly with this statement.
SELECT *
FROM demographic_data d
INNER JOIN demographic_info i
ON d.demographic_info_id = i.demographic_info_id
AND i.student_id = 1
BUT THEN grab the data from demographic_category WHERE the demographic_data.demographic_category_id DOESN'T exist IN demographic_category, so therefore grab the categories that doesn't exist in the ids from the query from above this paragraph.