안녕하세요 where절 분기처리에 관련해서 질문드립니다.
예를 들어
select
code_name
, code_status
from code, code_sub
where 1=1
and code.part_name = code_sub.part_name
and code.part_name = code_sub.sub_name
이러한 형태의 쿼리가 있다고 치면 아래처럼 각 로우에 code_status 값에 따라서
and절을 아래와 같은 형태로 조건을 거는게 가능한 방법인건지 질문드립니다.
select
code_name
, code_status
from code, code_sub
where 1=1
if(code_status ='U') {
and code.part_name = code_sub.part_name
} else {
and code.part_name = code_sub.sub_name
}