[DB_MySQL] 조건문
[mysql] 쿼리에서 조건문 사용 if 문, case 문, ifnull문 IF 문 형식 : if ( 조건문, 참일때 값, 거짓일때 값) EX) select member_id, if ( isnull(birthday), '-', birthday ) from member 설명 - 멤버 테이블에서 아이디(member_id) 와 생일을 뽑는데 null 일경우는 - 를 출력, 아니면 생일을 출력 Case 문 형식 : case (조건 또는 값) when 값1 then 표시값 when 값2 then 표시값 else 표시값 end EX) select case a when '1' then a when '2' then b else c end from table_name 설명 - a 값이 '1'이면 a, '2' 이면 b, ..