MySQL

MySQL) Reverse, Char_length, Ifnull 함수 사용하기

567Rabbit 2024. 5. 14. 16:36

reverse

-- 문자열의 순서를 역순으로 바꿔주는 함수 reverse()

 

 

-- author_lname 을 역순으로 가져오시오.
select reverse(author_lname)
from books;



 

 

char_length

 

-- 문자열의 갯수를 구하는 함수 char_length()

 

-- 책 제목의 글자 갯수를 구하세요.
select char_length(title) length, title
from books;

 

 

 

Ifnull

- Null인 항목을, 다른 값으로 채우는 방법

 

 

-- stock_quantity에 null이 있으면, 0으로 셋팅하자

select title, author_fname, author_lname, released_year,
ifnull(stock_quantity,0) as stock_quantity, pages
from books;