본문 바로가기
수업(국비지원)/Oracle

[Oracle] between 연산자

by byeolsub 2023. 4. 13.
  • between 연산자
where 컬럼명 between A and B : 컬럼 값이 A 이상 B 이하인 값.
                              문자열에서도 사용가능.
                              A 이상 B 초과는 사용 불가.

where 컬럼명 >= A and 컬럼명 <= B

문제 :
1.학생의 몸무게가 70 이상 80 이하인 학생의 이름,몸무게,학년 조회하기
select name, weight, grade from student where weight between 70 and 80;
select name, weight, grade from student where weight >= 70 and weight <= 80;  

💡

1. and : 두가지 조건을 모두 만족하는 결과를 원할때

             조건이 여러개이고 모두 만족하는 결과를 찾고 싶을때는 and 여러번 사용해도 된다.

2. or : 둘중 한가지만을 만족하는 행을 원할때

3. and 와 or 조건이 동시에 나올경우 우선순위 주의할것! // ()사용하여 잘 묶자.


문제 : 
2.교수테이블에서 교수의 급여가 300 이상 500 이하인 교수의 교수번호,이름,급여,보너스 조회하기
  select profno, name, pay, bonus from professor where pay between 300 and 500;
  select profno, name, pay, bonus from professor where pay >= 300 and pay <=500;

'수업(국비지원) > Oracle' 카테고리의 다른 글

[Oracle] like, not like 연산자  (0) 2023.04.13
[Oracle] in, not in 연산자  (0) 2023.04.13
[Oracle] distinct  (0) 2023.04.13
[Oracle] where 조건문  (0) 2023.04.13
[Oracle] 산술 연산자 : + ,-, *, /  (0) 2023.04.13