How about: SELECT LPAD(id,5,'10000'),user from table;
LPAD(str,len,padstr)
Returns the string str, left-padded with the string padstr to a length of
len characters. If str is longer than len, the return value is shortened
to len characters.
mysql> SELECT LPAD('hi',4,'??');
-> '??hi'
mysql> SELECT LPAD('hi',1,'??');
-> 'h'
On Fri, June 1, 2007 02:06, Ashley M. Kirchner wrote:
>
> Is there a way to automatically pad a query result? For example:
>
> select id, user from table
>
> +-----+--------------+
> | id | user |
> +-----+--------------+
> | 3 | Tinker Bell |
> | 11 | Peter Pan |
> | 7 | Dumbo |
> | 121 | Mickey Mouse |
> +-----+--------------+
>
> What I really want is:
>
> +-------+--------------+
> | id | user |
> +-------+--------------+
> | 10003 | Tinker Bell |
> | 10011 | Peter Pan |
> | 10007 | Dumbo |
> | 10121 | Mickey Mouse |
> +-------+--------------+
>
>
> --
> W | It's not a bug - it's an undocumented feature.
> +--------------------------------------------------------------------
> Ashley M. Kirchner <mailto:[EMAIL PROTECTED]> . 303.442.6410 x130
> IT Director / SysAdmin / Websmith . 800.441.3873 x130
> Photo Craft Imaging . 3550 Arapahoe Ave. #6
> http://www.pcraft.com ..... . . . Boulder, CO 80303, U.S.A.
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
>
>
> --
> This message has been scanned for viruses and
> dangerous content by OpenProtect(http://www.openprotect.com), and is
> believed to be clean.
>
--
Later
Mogens Melander
+45 40 85 71 38
+66 870 133 224
--
This message has been scanned for viruses and
dangerous content by OpenProtect(http://www.openprotect.com), and is
believed to be clean.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]