• Magne Mahre's avatar
    Bug#58970 Problem Subquery (without referencing a table) · 90650edf
    Magne Mahre authored
              and Order By
          
    When having a UNION statement in a subquery, with no
    referenced tables (or only a reference to the virtual
    table 'dual'), the UNION did not allow an ORDER BY clause.
          
          i.e:
              SELECT(SELECT 1 AS a UNION 
                     SELECT 0 AS a 
                     ORDER BY a) AS b  or
              SELECT(SELECT 1 AS a FROM dual UNION 
                     SELECT 0 as a 
                     ORDER BY a) AS b
          
          
    In addition, an ORDER BY / LIMIT clause was not accepted
    in subqueries even for single SELECT statements with no 
    referenced tables (or with 'dual' as table reference)
          
       i.e: 
          SELECT(SELECT 1 AS a ORDER BY a) AS b  or
          SELECT(SELECT 1 AS a FROM dual ORDER BY a) AS b
          
    The fix was to allow an optional ORDER BY/LIMIT clause to
    the grammar for these cases.
          
    See also: Bug#57986
    90650edf
union.result 50.2 KB