I want to add leading spaces in one of the column of the table. This ID column has data type Char(6).
Example: Table1
ID
1234
5678
when I do select * from Table1. and save file into .csv with pipeline delimited. It show spaces at the end of number.
Current output:
|1234 |
|5678 |
desired output
| 1234|
| 5678|
You'd need to trim
the value to remove the trailing spaces and then lpad
it to add the leading spaces
select lpad(trim(id),6)
from your_table
Here is a sqlfiddle example that shows the steps
尝试:
select LPAD(trim(id), 2) from table
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.