Description:
Output:
===
mysql> create table t1(c1 bigint);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 values(23057),(33006);
ct c1,Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> select c1, substr(c1, 2, 9) from t1 order by 2;
+-------+------------------+
| c1 | substr(c1, 2, 9) |
+-------+------------------+
| 33006 | 3006 |
| 23057 | 3057 |
+-------+------------------+
2 rows in set (0.00 sec)
mysql> select c1, substr(c1, 2, 10) from t1 order by 2;
+-------+-------------------+
| c1 | substr(c1, 2, 10) |
+-------+-------------------+
| 23057 | 3057 |
| 33006 | 3006 |
+-------+-------------------+
2 rows in set (0.00 sec)
mysql> select version();
+--------------+
| version() |
+--------------+
| 5.7.8-rc-log |
+--------------+
1 row in set (0.00 sec)
Problem:
====
The last query gives incorrect order, in which 3006 should be before 3057.
How to repeat:
drop table t1;
create table t1(c1 bigint);
insert into t1 values(23057),(33006);
select c1, substr(c1, 2, 9) from t1 order by 2;
select c1, substr(c1, 2, 10) from t1 order by 2;
Suggested fix:
The last query gives incorrect order, in which 3006 should be before 3057.