Bug #85492 counter-intuition behavior when dealing with alias
Description:
Sorry to bother you again.
At first sight this post is identical with Bug#85436 (https://bugs.mysql.com/bug.php?id=85436), while, it is not , maybe.
MySQL > create table t(a int, b int);
Query OK, 0 rows affected (0.05 sec)
MySQL > create table t1(a int, b int);
Query OK, 0 rows affected (0.04 sec)
MySQL > insert into t1 values(1,2);
Query OK, 1 row affected (0.04 sec)
MySQL > insert into t values(1,2);
Query OK, 1 row affected (0.04 sec)
OK, now, let us perform these statements one by one:
MySQL > select * from t, t;
ERROR 1066 (42000): Not unique table/alias: 't'
MySQL > select * from t1 as t, t;
ERROR 1066 (42000): Not unique table/alias: 't'
MySQL > select * from (select * from t1) t, (select * from t1) t;
ERROR 1066 (42000): Not unique table/alias: 't'
All failed. Let us move on please:
MySQL > select * from (select * from t1) as t, t;
+------+------+------+------+
| a | b | a | b |
+------+------+------+------+
| 1 | 2 | 1 | 2 |
+------+------+------+------+
1 row in set (0.03 sec)
It succeed.
After referring the doc of mysql5.6, I found nothing which can do me a favor to tell what is really going on here.
Would you please help me figure out what the rule and mechanism are when mysql resolves alias in a query ?
Is this a bug of mysql?
thank you very much.
How to repeat:
create table t(a int, b int);
create table t1(a int, b int);
insert into t1 values(1,2);
insert into t values(1,2);
select * from t, t;
select * from t1 as t, t;
select * from (select * from t1) t, (select * from t1) t;
select * from (select * from t1) as t, t;
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.056 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.