| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Paul DuBois | Date: | September 14 2002 11:23pm |
| Subject: | Re: Format can I Do this in MYSQL | ||
| View as plain text | |||
At 16:17 -0700 9/14/02, Bryan wrote: >Using ADO and a jet database I would often format a number so that it >could have a leading zero(s). For example > >Row Employee_number = 123 >Format(employee_number,"0000000") as EMPLOYEE would return 0000123 in >the EMPLOYEE column. I use it to align data for employeees who don't >have a 7 digit employee number. > >Is there a way of doing something like this in MySQL. You could try something like this: LPAD(col_name,7,'0') Or you could define your column to be a zerofill integer and have a display width of 7: mysql> create table t (i int(7) zerofill); Query OK, 0 rows affected (0.00 sec) mysql> insert into t set i = 13; Query OK, 1 row affected (0.01 sec) mysql> select * from t; +---------+ | i | +---------+ | 0000013 | +---------+ 1 row in set (0.00 sec)
| Thread | ||
|---|---|---|
| • data normalization question | speters | 6 Sep |
| • Re: data normalization question | Arthur Fuller | 14 Sep |
| • Re-sequencing a query result set with MYSQL | Dharmendra sawh | 14 Sep |
| • Re: Re-sequencing a query result set with MYSQL | Paul DuBois | 14 Sep |
| • RE: Re-sequencing a query result set with MYSQL | Dharmendra sawh | 14 Sep |
| • RE: Re-sequencing a query result set with MYSQL | Paul DuBois | 15 Sep |
| • Format can I Do this in MYSQL | Bryan | 15 Sep |
| • Re: Format can I Do this in MYSQL | Paul DuBois | 15 Sep |
| • RE: Format can I Do this in MYSQL | Bryan | 15 Sep |
| • Re: Format can I Do this in MYSQL | Jenny Barton | 16 Sep |
| • Re: Re-sequencing a query result set with MYSQL | peter.brawley | 15 Sep |
| • Re: data normalization question | BobJ | 14 Sep |
