RE: JOIN problem
Michael Ribbons <[email protected]> Tue, 28 Nov 2006 21:14:33 +1100
| Newsgroups | gmane.comp.db.mysql.bugs |
|---|---|
| Message-ID | <[email protected]> |
--_f137cb25-209a-4eb4-a6f1-98c020fb1f39_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks, and thanks to Valeriy Kravchuk too. > Date: Tue, 28 Nov 2006 11:06:22 +0100> From: [email protected]> To: mribb= [email protected]> CC: [email protected]> Subject: Re: JOIN problem> > Mic= hael Ribbons wrote:> > Hi, not sure if this is a bug or a feature added wit= h the changes for nested JOINs, > > this code works fine under 4.0.24, but = 2nd last query fails under 5.0.26.> > JOIN behavior was changed starting wi= th MySQL 5.0.12 to become> more ANSI compliant, check the "JOIN Syntax" man= ual page for> "Join Processing Changes in MySQL 5.0.12"> > vhttp://dev.mysq= l.com/doc/refman/5.0/en/join.html> > > > > Please observe the following sql= :> [...]> > SELECT ta.* FROM ta, tc LEFT JOIN tb ON tb.tb_id =3D ta.ta_id;>= > ERROR 1054 (42S22): Unknown column 'ta.ta_id' in 'on clause'> > * Previo= usly, the comma operator (,) and JOIN both had the same> precedence, so the= join expression t1, t2 JOIN t3 was interpreted> as ((t1, t2) JOIN t3). Now= JOIN has higher precedence, so the> expression is interpreted as (t1, (t2 = JOIN t3)). This change> affects statements that use an ON clause, because t= hat clause> can refer only to columns in the operands of the join, and the>= change in precedence changes interpretation of what those> operands are.> = > so rewriting the query like this should solve your problem:> > SELECT ta.= * FROM (ta, tc) LEFT JOIN tb ON tb.tb_id =3D ta.ta_id;> ^ ^> > > -- > Hartm= ut Holzgraefe, Senior Support Engineer .> MySQL AB, www.mysql.com>=20 _________________________________________________________________ Be one of the first to try Windows Live Mail. http://ideas.live.com/programpage.aspx?versionId=3D5d21c51a-b161-4314-9b0e-= 4911fb2b2e6d= --_f137cb25-209a-4eb4-a6f1-98c020fb1f39_--