having a bit of trouble visualizing how the connection should look for the specific result set that I am trying to achieve.
I have three tables: Projects, Recommendations, Services. Recommendations - this is just a table of connections between projects and services, that is, a project can have zero or more recommended services; To capture this relationship, the recommendation table has project_id and service_id for each recommendation record.
So the corresponding fields are:
Projects.id | Recommendations.project_id | Recommendations.service_id | Services.id
I am trying to list all projects for which there are no recommendations for a particular service. I have the following that pulls all projects for which there are no recommendations, and this:
SELECT * from projects P
LEFT OUTER JOIN Recommendations R ON P.id = R.project_id
WHERE R.project_id IS NULL
I know that I also need to join the Services table, but I'm not sure how to structure it. Any advice is appreciated.
source
share