The parens are for making sure the parsing works correctly. Probably either one works fine. Suggest you do EXPLAIN EXTENDED ...; SHOW WARNINGS; I suspect that the output from each will be identical, and have more parens.
The main need for parens is to avoid associating the ORDER BY with just the second SELECT. > -----Original Message----- > From: Hal?sz S?ndor [mailto:h...@tbbs.net] > Sent: Thursday, June 21, 2012 4:07 PM > To: mysql@lists.mysql.com > Subject: UNION and ORDER BY > > >>>> 2012/06/20 14:32 -0700, Rick James >>>> > ( > SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid1=xxx > UNION > SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid2=xxx > ) ORDER BY overlap DESC; > > Make it UNION ALL or UNION DISTINCT depending on whether xxx can be in > both fields of one row. UNION DISTINCT makes a pass over the temp > table to dedup. > <<<<<<<< > The help example shows a UNION s each SELECT separatly round-bracketed, > (SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid1=xxx) > UNION > (SELECT ruid1, ruid2, overlap FROM l4_link WHERE ruid2=xxx) > ORDER BY overlap DESC > but bracketing both is not mentioned. What is the difference? > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql