본문 바로가기
DATABASE

mysql - case when then end (조건문)

by YoonJong 2023. 1. 2.
728x90

 

select *, ( 
case 
	when CustomerSex = 0 then 'man'
    	when CustomerSex = 1 then 'woman'
else '미지정'
end 
) as '성별'
 from customer;

' 성별 ' 이라는 컬럼이 맨 마지막에 추가된다.

728x90

댓글