如何在MySQL中将前导零添加到不同的字符长度?
问题描述:
我对一个不同的表有一个查询,而且所有表的长度都不同,这要求ID
的前导零.是否可以使用一个查询来将前导零添加到任何表?
Hi,I have one query for different tables and all of them have different length which requires leading zero for the ID
. Is it possible to use one query that will add leading zero to any table?
让我们说第一个查询为insert to tbl1_field1(CHAR 3) 001
,然后下一个查询为insert to tbl2_field2(CHAR 4) 0001
,然后下一个为insert to tlb3_field3(CHAR 10) 0000000001
.我正在使用php and mysql
lets say first query is insert to tbl1_field1(CHAR 3) 001
, then next query is insert to tbl2_field2(CHAR 4) 0001
then next is insert to tlb3_field3(CHAR 10) 0000000001
. I am using php and mysql