Simple query failed: When alias used as column name and used in ORDER BY #796
Labels
kind/bug
Something isn't working
needs-triage
priority/p1
Medium priority feature that should be implemented in this version
severity/s1
High impact: Logical errors or data errors that must occur
Milestone
Can be reproduced ?
Yes
Steps:
CREATE TABLE t1 (spID int,userID int,score smallint);
INSERT INTO t1 VALUES (1,1,1);
INSERT INTO t1 VALUES (2,2,2);
INSERT INTO t1 VALUES (2,1,4);
INSERT INTO t1 VALUES (3,3,3);
INSERT INTO t1 VALUES (1,1,5);
INSERT INTO t1 VALUES (4,6,10);
INSERT INTO t1 VALUES (5,11,99);
select userID as user_id, spID sp_id from t1 order by user_id, sp_id;
Expected behavior:
mysql> select userID as user_id, spID sp_id from t1 order by user_id, sp_id;
+---------+-------+
| user_id | sp_id |
+---------+-------+
| 1 | 1 |
| 1 | 1 |
| 1 | 2 |
| 2 | 2 |
| 3 | 3 |
| 6 | 4 |
| 11 | 5 |
+---------+-------+
7 rows in set (0.00 sec)
Actual behavior:
mysql> select userID as user_id, spID sp_id from t1 order by user_id, sp_id;
ERROR 1105 (HY000): unknown error:[42000]unknown column 'user_id' in expr
Environment:
Configuration file:
Additional context:
The text was updated successfully, but these errors were encountered: