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

INSERT ... SELECT UNION with parenthesis

    XMLWordPrintable

Details

    Description

      I never noticed this or never thought it is a problem, but please look at this post:
      http://blog.mclaughlinsoftware.com/2014/06/15/mysql-insert-from-query/

      The "problem" is that parenthesis are allowed for INSERT (SELECT), but not for INSERT (SELECT UNION), and someone can conclude that INSERT SELECT UNION is not supported:

      MariaDB [test]> INSERT INTO t3 (SELECT a, NULL AS b FROM t2);
      Query OK, 3 rows affected (0.08 sec)
      Records: 3  Duplicates: 0  Warnings: 0
      MariaDB [test]> INSERT INTO t3 (SELECT a, NULL AS b FROM t1 UNION SELECT * FROM t2);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT * FROM t2)' at line 1
      MariaDB [test]> INSERT INTO t3 SELECT a, NULL AS b FROM t1 UNION SELECT * FROM t2;
      Query OK, 6 rows affected (0.08 sec)
      Records: 6  Duplicates: 0  Warnings: 0

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              f_razzoli Federico Razzoli
              Votes:
              0 Vote for this issue
              Watchers:
              7 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.