MySQL Forums
Forum List  »  Newbie

Re: many to many LEFT JOIN
Posted by: eykanal
Date: July 11, 2005 09:06AM

This has nothing to do with answering your question, but as an aside... it will make your code much easier to read if you use the "select ... as .." syntax. Example:

Original:
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

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

Options: ReplyQuote


Subject
Written By
Posted
July 11, 2005 07:59AM
July 12, 2005 07:23PM
Re: many to many LEFT JOIN
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.