개발공부

[MYSQL] 컬럼 합치기 concat(), concat_ws() 본문

Database/MySQL

[MYSQL] 컬럼 합치기 concat(), concat_ws()

mscha 2022. 5. 16. 11:46

아래와 같은 books 테이블이 있다.

 

컬럼 합치기 concat(), concat_ws()

author_fname과 author_lname을 합쳐서 full_name으로 가져오기

concat()

select concat(author_fname, ' ', author_lname) as full_name
from books;

concat_ws() 

첫번째 파라미터의 문자를 다른 컬럼이 올때마다 넣어서 붙인다.

select concat_ws(' ',author_fname, author_lname, pages)
from books;