본문 바로가기

IT/Mysql & MariaDB

[Mysql] 문자열 치환 함수 replace

1. Replace 함수란?

특정 문자열을 원하는 문자열로 변환하는 함수이다.

replace(컬럼명, '기존문자열', '변경문자열')

 

2. 사용 방법 

1) select

replace함수 실행 결과 추출하기

SELECT replace(url, 'http://' ,'https://') FROM file_info;

2) update 

'http://' 문자열이 포함된 컬럼을 'https://'로 변경

UPDATE file_info SET url = replace(url, 'http://' ,'https://');