Bug #3739 create table .. select, the same column name, unexpected error

Submitted: 13 May 2004 10:03 Modified: 13 May 2004 13:15
Reporter: Matthias Leich Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.0 OS:
Assigned to: CPU Architecture:Any

[13 May 2004 10:03] Matthias Leich
Description:
If a column of a table to be created and a column of a query table are equal,
the MySQL gives the wrong response 1060: Duplicate column name ...

simple examples:
  create table t2 ( a int ) select 1 ;      works OK

  create table t2 ( a int ) select 1 as a;  fails

  create table t2 ( a int ) select 1 as b;  works OK

  create table t2 ( a int ) select a from t1; fails

This error occurs in version 4.0 only.

The behaviour of version 4.1 and 5.0 is correct.

My environment: Linux(SuSE 9.0), MySQL 4.0 source distrib 
                                (last bkpull ~7.5.2004)

How to repeat:
Please have a look at the examples above.
[13 May 2004 13:15] Sergei Golubchik
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.mysql.com/documentation/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

Additional info:

From the manual (CREATE TABLE section):

...
Notice that the columns from the `SELECT' statement are appended to the
right side of the table, not overlapped onto it.
...

so

 create table t2 ( a int ) select 1 as a;

results in

   create table t2 (a int, a int)

with the following "Duplicate column name" error

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.048 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.