如何在MySQL中将前导零添加到不同的字符长度? [英] How to add leading zero to different char length in mysql?
本文介绍了如何在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
推荐答案
the query will show a string like this - '0001'
.
这篇关于如何在MySQL中将前导零添加到不同的字符长度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文