在MySQL更新,这将是9个位数MYSQL列的更新
例如在列中的数字:
658 were recorded, but must be 000000658,
if 96258, this must be 000096258, front contributed to 0.
感谢
在MySQL更新,这将是9个位数MYSQL列的更新
例如在列中的数字:
658 were recorded, but must be 000000658,
if 96258, this must be 000096258, front contributed to 0.
感谢
在创建列中使用此:
ALTER table `table` CHANGE `column` `column` VARCHAR(9);
在插入或更新数据使用:
UPDATE table SET `column` = LPAD(`column`, 9, '0'); #pads everything
我认为你必须改变从数据类型int到varchar(9)。在提交到数据库之前,只需在代码中添加代码。
例子在PHP中:
$foo = "604";
while(strlen($foo) < 9)
{
$foo = "0".$foo;
}
$ foo的现在等于000000604.所有你需要做的是写一个循环从数据库拉,并承诺回去吧。
我认为标签是用'mysql' –
的,什么是你试过吗? –
这就是渲染。保存数据在数据库中,留下渲染到UI – Bohemian
重复:http://stackoverflow.com/questions/5191494/padding-the-beginning-of-a-mysql-int-field-with-zeroes? –