D/MySQL

[MySQL] RPAD()

yeon.Biju 2020. 4. 20. 12:20

MySQL 문자열 함수와 연산자

 

RPAD()

   -

 

RPAD(str, len, padstr)

의 형태

 

Returns the string str, right-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 RPAD('hello', '10', '?' );
+---------------------------+
| RPAD('hello', '10', '?' ) |
+---------------------------+
| hello?????                |
+---------------------------+
1 row in set (0.00 sec)

 

mysql> SELECT RPAD('hello', '2', '?' );
+--------------------------+
| RPAD('hello', '2', '?' ) |
+--------------------------+
| he                       |
+--------------------------+
1 row in set (0.00 sec)