Description:
BECOME FULL RESULTS
SHOULD NOT HAVE THAT BEHAVIOR
ME ELIMINATES ZEROFILL.
How to repeat:
C:\Program Files\EasyPHP-DevServer-14.1VC9\binaries\mysql\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 329
Server version: 5.6.15-log MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> USE bug;
Database changed
mysql> SHOW COLUMNS FROM table1;
+--------+--------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+--------------------------+------+-----+---------+----------------+
| id | int(11) unsigned | NO | PRI | NULL | auto_increment |
| number | int(3) unsigned zerofill | NO | | 001 | |
| name | varchar(10) | NO | | NULL | |
+--------+--------------------------+------+-----+---------+----------------+
3 rows in set (0.01 sec)
mysql> SELECT DISTINCT CONCAT(x.id,'-',x.number,'-',x.name) FROM table1 AS x;
+--------------------------------------+
| CONCAT(x.id,'-',x.number,'-',x.name) |
+--------------------------------------+
| 1-001-xxx |
| 2-002-yyy |
+--------------------------------------+
2 rows in set (0.00 sec)
mysql> SELECT DISTINCT CONCAT(x.id,'-',(SELECT xx.number FROM table1 AS xx WHERE x.id=xx.id),'-',x.name) FROM table1 AS x;
+-----------------------------------------------------------------------------------+
| CONCAT(x.id,'-',(SELECT xx.number FROM table1 AS xx WHERE x.id=xx.id),'-',x.name) |
+-----------------------------------------------------------------------------------+
| 1-1-xxx |
| 2-2-yyy |
+-----------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql>