MySQL Forums
Forum List  »  PHP

Re: trouble figuring out joins, any gurus out there?
Posted by: Rick James
Date: September 01, 2009 10:30PM

Plain 'ole JOIN.
INNER and OUTER -- usually just noise.
LEFT and RIGHT -- only useful for checking for missing rows in one of the tables.
STRAIGHT -- only when you thing you are smarter than the optimizer.
And, usually you don't need to worry about the order of tables.

SELECT  p.project_name,
        t.title
      FROM project_tag pt
      JOIN project p   ON p.project_id = pt.project_id
      JOIN tag t       ON pt.tag_id = t.tag_id
      JOIN todo_tag dt ON dt.tag_id = pt.tag_id
      JOIN todo d      ON t.todo_id = dt.todo_id
   WHERE pt.project_id = 1

Options: ReplyQuote


Subject
Written By
Posted
Re: trouble figuring out joins, any gurus out there?
September 01, 2009 10:30PM


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.