最佳答案
在我的 MySQLInnoDB 数据库中,有一些脏的邮政编码数据需要清理。
干净的邮政编码数据是当我有一个邮政编码的全部5位数字(例如“90210”)。
但出于某种原因,我注意到在我的数据库中,对于以“0”开头的邮政编码,0被删除了。
因此,“ 霍尔茨维尔”与邮政编码“ 00544
”是存储在我的数据库作为“ 544
”
还有
“ 戴德姆”与邮政编码“ 02026
”是存储在我的数据库作为“ 2026
”。
我可以运行什么 SQL 前垫“0”到任何邮政编码,不是5位数字的长度?意思是,如果邮政编码是3位数字的长度,前垫“00”。如果邮政编码是4位数字的长度,前垫只有“0”。
更新 :
我只是将邮政编码改为数据类型 VARCHAR (5)