WHERE

KITRI기술연수/ORACLE 2010. 5. 18. 12:36

WHERE

1. AND
2. OR
3. BETWEEN AND
4. IN()
5. IS NULL/IS NOT NULL
6. LIKE


WHERE

1. AND OR

예)
SELECT employee_id
      , last_name
      , department_id
      , job_id
FROM employees
WHERE last_name = 'Gee' OR last_name = 'Smith';


2. BETWEEN AND

기본적 AND 있지만 쉽게 쓰기위해서

예)
SELECT employee_id
      , last_name
      , department_id
      , job_id
FROM employees
WHERE salary BETWEEN 8000 AND 10000;

3. IN()
이녀석도 OR 쉽게 쓰기위해

예)
SELECT employee_id
      , last_name
      , department_id
      , job_id
FROM employees
WHERE last_name IN ('Gee','Smith');



4. IS NULL

예)

--부서를 발령바디 않은 사원의 정보를얻자
--사원번호 이름(성) 입사일자 부서ID

SELECT employee_id
      , last_name
      , hire_date
      , department_id
FROM employees
WHERE department_id IS NULL;

5. LIKE

예)
--1999년 입자사 중에서 영업사원 이거나 급여를 3000 이하를 받는 사원의 정보를 얻자

SELECT employee_id
      , last_name
      , hire_date
      , job_id
      , salary
FROM employees
WHERE hire_date LIKE '99%'
    --AND job_id IN ('SA_MAN', 'SA_REP);
AND (job_id LIKE 'SA%'OR salary <= 3000);

: