Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-24771

Column alias in UNION with GROUP BY query

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 10.3.25
    • Fix Version/s: N/A
    • Component/s: N/A
    • Labels:
    • Environment:
      Ubuntu 20.04.1

      Description

      Simplified sample query
      SELECT greet FROM (SELECT 'hi' AS greet
      UNION SELECT 'hello'
      FROM (SELECT '') AS _ GROUP BY NULL) AS tbl WHERE greet != ''

      Actual result
      [mysqli: 1054] Unknown column 'greet' in 'order clause'

      Expected result
      Query passes (returns 'hihello')

      Additional info
      The following changes each make the query pass:

      • Change line 2 to UNION SELECT 'hello' AS greet
      • Remove the GROUP BY NULL clause

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              evilliger Elias Villiger
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.