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 |
Hi,
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|
|
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 |
How about: SELECT LPAD(id,5,'1'),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