백엔드/DB

[MariaDB] MariaDB 학습 - SQL문 - 문자 함수

tero1115 2023. 7. 7. 17:17

substring()

-- 문자 함수
-- SQL에서는 문자열 등 배열의 시작이 0이아니라 1이다
-- substring(문자열, 시작위치, 개수)

-- 문자 함수
-- SQL에서는 문자열 등 배열의 시작이 0이아니라 1이다
-- substring(문자열, 시작위치, 개수)
select first_name,phone_number, substring(phone_number, 1, 3)
from employees;

 

 

replace()

-- 문자열 치환
-- replace(문자열, 치환될 문자, 치환할 문자)

-- 문자열 치환
-- replace(문자열, 치환될 문자, 치환할 문자)
select first_name, replace(phone_number, '515', '010')
from employees;

 

 

upper

-- 문자열 대문자로 바꾸기

-- 문자열 대문자로 바꾸기
select upper(first_name)
from employees;