[SQL] (where)특정문자 한개 이상의 옵션이 있는 데이터 선택하기

도리·2025년 2월 14일
post-thumbnail

programmers lv2. 자동차 종류 별 특정 옵션이 포함된 자동차 수 구하기

where절에 특정조건이 있는 데이터 선택하기

틀린코드

where options in ('%통풍시트%'or'%열선시트%'or'%가죽시트%')

정답코드 1

where options like '%통풍시트%'
	or options like '%열선시트%'
	or options like '%가죽시트%'

정답코드 2

where options regexp '통풍시트|열선시트|가죽시트'

틀린이유 : in은 정확히 일치하는 값을 비교하는데 사용된다. in %%는 같이 못씀.

cf. 반대도 가능하다.

programmers lv1.python 개발자 찾기 문제

where 'Python' in (skill_1, skill_2, skill_3)
  • Python은 데이터 값. skill_1, skill_2, skill_3은 column 이름이다.
    SELECT ID,EMAIL,FIRST_NAME,LAST_NAME
    FROM DEVELOPER_INFOS
    WHERE 'Python' IN (SKILL_1,SKILL_2,SKILL_3)
    ORDER BY ID
profile
인공지능응용학과 졸업

0개의 댓글