I was just trying to figure out how to print an stored value of integer having 0 pre appended with it.
The best and good way to prepend zero integer value for a integer of fixed size is to alter the table having "UNSIGNED ZEROFILL" as an attribute for the field which needs zero prepended with it.
CREATE TABLE IF NOT EXISTS `table_1` (
`ID` int(11) NOT NULL auto_increment,
`some_id` int(6) unsigned zerofill NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=8321 ;
You can do when data is present and you want to do this.
ALTER TABLE `table_1` CHANGE `some_id` `some_id` INT( 6 ) UNSIGNED ZEROFILL NOT NULL
feel free to express your thoughts too.
No comments:
Post a Comment