# replace 문자  치환하기

문자열 내에서 특정 부분 문자열을 다른 문자열로 대체하는 함수다.

```
replace(string, target, replacement)
```

string에는 문자열 혹은 컬럼이나 필드가 올 수 있다.

target에는 바꾸려는 문자열을 넣어준다.

replacement에는 대체할 문자열을 넣어준다.

1. 직접 문자열을 입력하는 경우

```
select replace('hello world', 'world', 'there')
>> 결과 : hello there
```

string에 'hello world'를 넣고 world를 there로 대체하는 식이다.

1. 테이블의 특정 컬럼을 지정하는 경우

```
sellect replace(job_id, 'engineer', '엔지니어')
from employees 
>> 결과 : 엔지니어
```

string에 컬럼을 넣어 영어로 표기된 engineer를 모두 한글로 표기된 엔지니어로 대체한다.

1. 여러 문자열을 변환하는 경우

```
sellect replace(replace(job_id, 'engineer', '엔지니어'), 'desinger', '디자이너')
from employees 
```

만약 한 컬럼에서 여러 문자열을 변경하고 싶다면 replace로 한 번 더 묶어서 적어주면 된다.

For the site tree, see the [root Markdown](https://slashpage.com/kyugntae-ai.md).
