如何将列中的所有值修改为固定的 9 位数字以及每个以常量 int 405 开头的结果 eg.51=405000051
How do I amend all values in a column to a fixed 9 digits and the results of each beginning with a constant int 405 eg.51=405000051
我需要从 table 导出一些客户余额并导入到另一个。但是 customer_ID 列不是固定的,需要固定,值是 3 到 5 位数字(例如 322…4144…11833)。
我想将带有 customer_ID 和 customer_bals 的数据导出到 csv,其中 customer_id 列中的值固定为 9 位数字,所有数字都以常量 405 开头在每个值的开头。例如。 405000322…405004144 和 405011833.
如何在 MySQL Workbench 中编写此查询?
使用LPAD
函数添加前导零,CONCAT()
连接固定前缀。
CONCAT('405', LPAD(customerID, 6, '0'))
我需要从 table 导出一些客户余额并导入到另一个。但是 customer_ID 列不是固定的,需要固定,值是 3 到 5 位数字(例如 322…4144…11833)。
我想将带有 customer_ID 和 customer_bals 的数据导出到 csv,其中 customer_id 列中的值固定为 9 位数字,所有数字都以常量 405 开头在每个值的开头。例如。 405000322…405004144 和 405011833.
如何在 MySQL Workbench 中编写此查询?
使用LPAD
函数添加前导零,CONCAT()
连接固定前缀。
CONCAT('405', LPAD(customerID, 6, '0'))