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
|
{"report":{"fcp":1157.7999999523163,"ttfb":297.2999999523163,"pageVisibility":"visible","entityId":38532,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"9daf407d-5cf4-4bf4-ad64-c1f2a57feb62","navigationType":0,"readyForUser":1237.2999999523163,"redirectCount":0,"resourceLoadedEnd":900.3999999761581,"resourceLoadedStart":305.89999997615814,"resourceTiming":[{"duration":257.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":305.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":305.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":563.5,"responseStart":0,"secureConnectionStart":0},{"duration":257.40000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":306.1999999284744,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":306.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":563.6000000238419,"responseStart":0,"secureConnectionStart":0},{"duration":467.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":306.2999999523163,"connectEnd":306.2999999523163,"connectStart":306.2999999523163,"domainLookupEnd":306.2999999523163,"domainLookupStart":306.2999999523163,"fetchStart":306.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":568,"responseEnd":773.8999999761581,"responseStart":586.2999999523163,"secureConnectionStart":306.2999999523163},{"duration":593.1000000238419,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":307.2999999523163,"connectEnd":307.2999999523163,"connectStart":307.2999999523163,"domainLookupEnd":307.2999999523163,"domainLookupStart":307.2999999523163,"fetchStart":307.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":568.6000000238419,"responseEnd":900.3999999761581,"responseStart":588,"secureConnectionStart":307.2999999523163},{"duration":284.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":307.39999997615814,"connectEnd":307.39999997615814,"connectStart":307.39999997615814,"domainLookupEnd":307.39999997615814,"domainLookupStart":307.39999997615814,"fetchStart":307.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":569.1000000238419,"responseEnd":592.2999999523163,"responseStart":589.1999999284744,"secureConnectionStart":307.39999997615814},{"duration":288.1999999284744,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":307.60000002384186,"connectEnd":307.60000002384186,"connectStart":307.60000002384186,"domainLookupEnd":307.60000002384186,"domainLookupStart":307.60000002384186,"fetchStart":307.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":570,"responseEnd":595.7999999523163,"responseStart":593.1000000238419,"secureConnectionStart":307.60000002384186},{"duration":288.89999997615814,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":307.60000002384186,"connectEnd":307.60000002384186,"connectStart":307.60000002384186,"domainLookupEnd":307.60000002384186,"domainLookupStart":307.60000002384186,"fetchStart":307.60000002384186,"redirectEnd":0,"redirectStart":0,"requestStart":570.2999999523163,"responseEnd":596.5,"responseStart":593.7999999523163,"secureConnectionStart":307.60000002384186},{"duration":260.5,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":307.6999999284744,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":307.6999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":568.1999999284744,"responseStart":0,"secureConnectionStart":0},{"duration":262.60000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":307.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":307.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":570.5,"responseStart":0,"secureConnectionStart":0},{"duration":325.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":307.89999997615814,"connectEnd":307.89999997615814,"connectStart":307.89999997615814,"domainLookupEnd":307.89999997615814,"domainLookupStart":307.89999997615814,"fetchStart":307.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":573.1000000238419,"responseEnd":633.3999999761581,"responseStart":631.1000000238419,"secureConnectionStart":307.89999997615814},{"duration":291.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":308,"connectEnd":308,"connectStart":308,"domainLookupEnd":308,"domainLookupStart":308,"fetchStart":308,"redirectEnd":0,"redirectStart":0,"requestStart":573.2999999523163,"responseEnd":599.5,"responseStart":597,"secureConnectionStart":308},{"duration":571.7999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":308.89999997615814,"connectEnd":308.89999997615814,"connectStart":308.89999997615814,"domainLookupEnd":308.89999997615814,"domainLookupStart":308.89999997615814,"fetchStart":308.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":660.3999999761581,"responseEnd":880.6999999284744,"responseStart":875.1000000238419,"secureConnectionStart":308.89999997615814},{"duration":573.6000000238419,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":309.89999997615814,"connectEnd":309.89999997615814,"connectStart":309.89999997615814,"domainLookupEnd":309.89999997615814,"domainLookupStart":309.89999997615814,"fetchStart":309.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":755.6999999284744,"responseEnd":883.5,"responseStart":879.6000000238419,"secureConnectionStart":309.89999997615814},{"duration":245.69999992847443,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":902.1000000238419,"connectEnd":902.1000000238419,"connectStart":902.1000000238419,"domainLookupEnd":902.1000000238419,"domainLookupStart":902.1000000238419,"fetchStart":902.1000000238419,"redirectEnd":0,"redirectStart":0,"requestStart":1118.7999999523163,"responseEnd":1147.7999999523163,"responseStart":1147.1000000238419,"secureConnectionStart":902.1000000238419}],"fetchStart":1,"domainLookupStart":20,"domainLookupEnd":39,"connectStart":39,"connectEnd":57,"secureConnectionStart":47,"requestStart":58,"responseStart":298,"responseEnd":308,"domLoading":301,"domInteractive":1318,"domContentLoadedEventStart":1318,"domContentLoadedEventEnd":1376,"domComplete":2075,"loadEventStart":2075,"loadEventEnd":2075,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1289.8999999761581},{"name":"bigPipe.sidebar-id.end","time":1290.6999999284744},{"name":"bigPipe.activity-panel-pipe-id.start","time":1290.8999999761581},{"name":"bigPipe.activity-panel-pipe-id.end","time":1293.6999999284744},{"name":"activityTabFullyLoaded","time":1392.6000000238419}],"measures":[],"correlationId":"6a55e0a1a13bc0","effectiveType":"4g","downlink":9.7,"rtt":0,"serverDuration":109,"dbReadsTimeInMs":13,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
considering: https://mariadb.com/kb/en/insert-select/
MariaDB [test]> INSERT INTO t3 (SELECT a, NULL AS b FROM t2);
this should not work
MariaDB [test]> INSERT INTO t3 (SELECT a, NULL AS b FROM t1 UNION SELECT * FROM t2);
this should not work
MariaDB [test]> INSERT INTO t3 SELECT a, NULL AS b FROM t1 UNION SELECT * FROM t2;
this should work