7. 사원번호가 7654와 7782 사이 이외의 사원의 모든 정보를 출력할 때

김미숙's avatar
Jul 15, 2025
7. 사원번호가 7654와 7782 사이 이외의 사원의 모든 정보를 출력할 때

내가 입력한 코드

select * from emp where empno between 7654 and 7782;
notion image
💡
‘between 7654 and 7782’ 은 7654와 7782 사이의 번호를 출력한다
문제는 7654와 7782 사이 이외의 번호를 출력하는 것이었으므로 not이 필요! → ‘not between 7654 and 7782’
사원번호가 7654보다 작거나 7782보다 큰 사원만 조회하는 것으로도 가능 → empno < 7654 or empno > 7782
 

🛠 해결

select * from emp where empno not between 7654 and 7782;
notion image

이렇게도 가능하다

select * from emp where empno < 7654 or empno > 7782;
notion image
Share article

parangdajavous