I need to add a "0" before a integer field in a MYSQL table. How do I update those fields so t开发者_C百科hey have a ) added to them? Thanks.
You can't unless you change the column type to string. However you can add the zero when reading the field:
SELECT CONCAT( '0', int_col ) FROM ....
If you want to format the output of all integer values in one column to a fixed column size, say 5, with leading zeroes for small numbers, use an ALTER TABLE statement like:
ALTER TABLE table MODIFY `col` INT(5) ZEROFILL;
Refer to MySQL 5.1 Reference Manual.
精彩评论