「MySQL」RPAD 関数で0右埋めを行う

書式
RPAD(str,len,padstr)
RPAD 関数は右詰めした文字列を取得します

使用例
SQL構文

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
SELECT RPAD(8, 1, 0) resA,RPAD(8, 2, 0) resB,RPAD(8, 3, 0) resC,RPAD(8, 4, 0) resD
SELECT RPAD(8, 1, 0) resA,RPAD(8, 2, 0) resB,RPAD(8, 3, 0) resC,RPAD(8, 4, 0) resD
SELECT RPAD(8, 1, 0) resA,RPAD(8, 2, 0) resB,RPAD(8, 3, 0) resC,RPAD(8, 4, 0) resD

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
resA resB resC resD
8 80 800 8000
resA resB resC resD 8 80 800 8000
resA	resB	resC	resD
8	80	800	8000

 

MySQL

Posted by arkgame