[OT] Why I don't use SQL Joins if I can help it
bobsneidar at iotecdigital.com
Tue Dec 27 17:41:44 EST 2016
An excerpt from the MySQL 5.7 reference manual. What grabbed my attention was the last part of the Note, "Also, some queries that appeared to work correctly in older versions (prior to 5.0.12) must be rewritten to comply with the standard." WHAA??? They changed the engine so that joins that used to work would suddenly produce different results???
Join Processing Changes in MySQL 5.0.12
Natural joins and joins with USING, including outer join variants, are processed according to the SQL:2003 standard. The goal was to align the syntax and semantics of MySQL with respect to NATURAL JOIN and JOIN ... USING according to SQL:2003. However, these changes in join processing can result in different output columns for some joins. Also, some queries that appeared to work correctly in older versions (prior to 5.0.12) must be rewritten to comply with the standard.
These changes have five main aspects:
• The way that MySQL determines the result columns of NATURAL or USING join operations (and thus the result of the entire FROM clause).
• Expansion of SELECT * and SELECT tbl_name.* into a list of selected columns.
• Resolution of column names in NATURAL or USING joins.
• Transformation of NATURAL or USING joins into JOIN ... ON.
• Resolution of column names in the ON condition of a JOIN ... ON.
The following list provides more detail about several effects of current join processing versus join processing in older versions. The term “previously” means “prior to MySQL 5.0.12.”
• The columns of a NATURAL join or a USING join may be different from previously. Specifically, redundant output columns no longer appear, and the order of columns for SELECT * expansion may be different from before.
More information about the use-livecode