I am trying to join a 3 tables. projects, statuses, clients. The GOAL of the query should result in all projects that have a current status of “Received”. I am also trying to grab the client name for displaying in the resulting table.
These tables have common foreign keys as: client_ID, status_ID.
Here is my query thus far. I am trying hard to get a better understanding of joins. If you can provide comments on what I am doing wrong and example code that would be very much appriciated.
SELECT clients.clientName,
clients.Client_ID,
projects.Client_ID,
projects.projectNumber,
projects.projectName,
projects.expectedDate,
statuses.Status_ID,
statuses.status
FROM projects,
clients,
statuses
LEFT JOIN clients on projects.Client_ID = clients.Client_ID
LEFT JOIN statuses on projects.Status_ID = statuses.Status_ID
WHERE status = 'Received'
Try using ‘JOIN’ instead of ‘LEFT JOIN’. Also remove clients and statuses in the from clause. I would also query the Status_ID instead of the status name.