| Bug #63233 | FROM DUAL raises error with alias and ORDER BY | ||
|---|---|---|---|
| Submitted: | 13 Nov 2011 16:39 | Modified: | 14 Jul 2015 10:44 |
| Reporter: | Peter Laursen (Basic Quality Contributor) | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Parser | Severity: | S3 (Non-critical) |
| Version: | 5.1.59 - probably any | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | qc | ||
[13 Nov 2011 16:39]
Peter Laursen
[13 Nov 2011 16:40]
Peter Laursen
Fixed typo in synopsis.
[13 Nov 2011 17:18]
Valeriy Kravchuk
Thank you for the problem report. Here I'd say we do have a bug, as this works: mysql> explain extended SELECT 1 AS no1, 2 AS no2 order by no2; +----+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+ | 1 | SIMPLE | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | No tables used | +----+-------------+-------+------+---------------+------+---------+------+------+----------+----------------+ 1 row in set, 1 warning (0.00 sec) mysql> show warnings\G *************************** 1. row *************************** Level: Note Code: 1003 Message: select 1 AS `no1`,2 AS `no2` order by 2 1 row in set (0.00 sec)
[13 Nov 2011 19:23]
Peter Laursen
a similar discussion here: http://bugs.mysql.com/bug.php?id=63234
[14 Nov 2011 8:56]
Peter Laursen
Actually I can use any non-empty table as the 'dummy' table.
SELECT * FROM t1;
/*
id
------
3
4
*/
SELECT 1 AS no1, 2 AS no2 FROM t1 ORDER BY no2 LIMIT 1;
/* returns
no1 no2
------ ------
1 2
*/
I may even "CREATE TABLE `dual` .. ;", insert one or more rows into it and use this one
SELECT 1 AS no1, 2 AS no2 FROM `dual` ORDER BY no2 LIMIT 1;
[14 Jul 2015 10:37]
Øystein Grøvlen
Posted by developer: This was fixed in 5.7.4 by the fix for bug#17703542: mysql> select version(); No connection. Trying to reconnect... Connection id: 1 Current database: dbt3 +-----------+ | version() | +-----------+ | 5.7.4-m14 | +-----------+ 1 row in set (0.00 sec) mysql> SELECT 1 AS no1, 2 AS no2 FROM DUAL ORDER BY no2; +-----+-----+ | no1 | no2 | +-----+-----+ | 1 | 2 | +-----+-----+ 1 row in set (0.00 sec)
