Bug #1821 parentheses after insert into
Submitted: 12 Nov 2003 15:09 Modified: 13 Nov 2003 11:05
Reporter: Jan-Peter Wilhelms Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.0-alpha OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any

[12 Nov 2003 15:09] Jan-Peter Wilhelms
Description:
The statement
INSERT INTO T1 (SELECT ID FROM T2) UNION (SELECT ID FROM T3);
gives an error:
ERROR 1064: You have an error in your SQL syntax.

Even the statement
INSERT INTO T1 (SELECT ID FROM T2);
produces the same error message.

The parentheses should work in this context!

How to repeat:
create table t1 (id integer);
create table t2 (id integer);
create table t3 (id integer);
INSERT INTO T1 (SELECT ID FROM T2) UNION (SELECT ID FROM T3);
[13 Nov 2003 8:02] Georg Richter
Your Syntax is wrong, correct would be 
 
INSERT INTO T1 (SELECT ID FROM T2 UNION SELECT ID FROM T3); 
 
but this fails also in 4.1.1 
 
INSERT INTO T1 (SELECT ID FROM T2) works correct in 4.1.1
[13 Nov 2003 11:05] Sergei Golubchik
actually

INSERT INTO T1 (SELECT ID FROM T2) UNION (SELECT ID FROM T3);

is correct. The reason it's not supported in 4.1.0 is because it wasn't trivial for the parser to distinguish it from

INSERT INTO T1 (column-list) VALUES ...

after reading the first '('.

But it's all solved in 4.1.1 and this syntax is correctly recognised and supported.