MySQL生成指定长度字符串LPAD/RPAD
左侧填充使用LPAD
mysql> select lpad(123, 7, 0);
# 输出
+-----------------+
| lpad(123, 7, 0) |
+-----------------+
| 0000123 |
+-----------------+
1 row in set (0.21 sec)
右侧填充使用RPAD
mysql> select rpad(123, 6,'0');
# 输出
+------------------+
| rpad(123, 6,'0') |
+------------------+
| 123000 |
+------------------+
1 row in set (0.09 sec)