List:General Discussion« Previous MessageNext Message »
From:(Hal Date:June 21 2012 11:06pm
Subject:UNION and ORDER BY
View as plain text  
>>>> 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?

Thread
Indexing about 40 Billion EntriesChristian Koetteritzsch20 Jun
  • Re: Indexing about 40 Billion EntriesAnanda Kumar20 Jun
    • RE: Indexing about 40 Billion EntriesRick James20 Jun
      • Re: Indexing about 40 Billion EntriesChristian Koetteritzsch20 Jun
        • Re: Indexing about 40 Billion EntriesChristian Koetteritzsch20 Jun
        • RE: Indexing about 40 Billion EntriesRick James20 Jun
          • Re: Indexing about 40 Billion EntriesChristian Koetteritzsch21 Jun
            • Re: Indexing about 40 Billion Entriesmos21 Jun
              • Re: Indexing about 40 Billion EntriesChristian Koetteritzsch21 Jun
              • RE: Indexing about 40 Billion EntriesRick James21 Jun
          • UNION and ORDER BYhsv22 Jun
            • RE: UNION and ORDER BYRick James22 Jun
  • Re: Indexing about 40 Billion EntriesShawn Green20 Jun
    • RE: Indexing about 40 Billion EntriesRick James20 Jun
  • Re: Indexing about 40 Billion EntriesBrent Clark21 Jun