MySQL Forums
Forum List  »  Newbie

many to many LEFT JOIN
Posted by: cadex
Date: July 11, 2005 07:59AM

Hello, I was wondering if someone could help me out. I've got 3 tables; a project table; a store table and a completion table. The completion table has a combined primary key using the project ID from the project table and the store ID from the store table, and then it has a few more fields for comments and completion status.

Anyway, what I'm trying to do is get a list of all the stores regardless of whether they even have an entry in the completion table, and then for each of those stores I want the completion status. I thought for sure the left join would work, but it still seems to only get stores for which there is a corresponding entry in the completion table.

Any ideas? here is my query:

SELECT nis_store.id_store, nis_project.id, nis_project.billingcode, nis_project.subject, nis_completion.comments, nis_completion.completed, nis_completion.na, nis_completion.project_id
FROM nis_store LEFT JOIN nis_completion ON nis_store.id_store = nis_completion.store_id LEFT JOIN nis_project ON nis_project.id = nis_completion.project_id AND '" . $_GET['select_project'] . "' = nis_project.id
ORDER BY nis_store.id_store

Thanks!
Kyle

Options: ReplyQuote


Subject
Written By
Posted
many to many LEFT JOIN
July 11, 2005 07:59AM
July 12, 2005 07:23PM
July 11, 2005 09:06AM
July 13, 2005 01:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.