hello world

이름 마스킹처리 MYSQL 본문

WEB/DB

이름 마스킹처리 MYSQL

sohyun_92 2022. 11. 11. 18:39
728x90
    select 
        CASE WHEN CHAR_LENGTH(name) > 2 THEN 
            concat(
                substring(name, 1, 1)
                ,LPAD('*', CHAR_LENGTH(name) - 2, '*')
                ,SUBSTRING(name, CHAR_LENGTH(name), CHAR_LENGTH(name)) 
            )
        ELSE
            CONCAT(
                SUBSTRING(name, 1, 1)
                ,LPAD('*', CHAR_LENGTH(name) - 1, '*')
            )
        END
        as name_masking

 

Comments