MySQL Forums
Forum List  »  Newbie

Re: Difference between two SQL queries
Posted by: laptop alias
Date: July 16, 2011 05:24AM

Inner joins can be expressed in two ways - either explicitly, e.g.:

SELECT *
  FROM x
 INNER
  JOIN y
    ON y.id = x.id;

or implicitly, e.g.

SELECT *
  FROM x,y
 WHERE y.id = x.id;

Although these queries are logically identical, MySQL actually places precedence on one kind of join over another. In more complicated queries this can lead to unpredictable behaviour (from the point of view of us humans anyway). Also, an explicit join is easier to read and modify than an implicit join. For these reasons, around here we tend to avoid the implicit variety - the exception being the CROSS JOIN which is just an INNER JOIN without a join condition. Note also that in MySQL the INNER keyword (like its OUTER counterpart) is optional and frequently omitted.

Finally, you must be able to find a more elegant age calculator than that monstrosity!



Edited 2 time(s). Last edit at 07/16/2011 05:28AM by laptop alias.

Options: ReplyQuote


Subject
Written By
Posted
Re: Difference between two SQL queries
July 16, 2011 05:24AM


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.