DQL(Data Query Language)
: 데이터의 조회를 수행하는 SQLSELECT
SELECT
: 데이터를 조회하는 SQL- 형식
select 컬럼명, 컬럼명, ....
from 테이블명
where 컬럼명 연산자 값 and/or 컬럼명 연산자 값 ....
ex>
select MNAME, PHONE
from MEMBERS
where MNAME = '임꺽정' and PHONE = '111-1112';
select *
from MEMBERS
where MNAME = '임꺽정' and PHONE = '111-1112';
기본 연산자
: <, >, <=, >=, <>ex>
select *
from MEMBERS
where
REG_DATE >= '2013-08-12' and REG_DATE < '2013-08-15';
like 연산자
- %: 0자 이상- _: 1자
ex>
select *
from MEMBERS
where MNAME like '임%'
;
select *
from MEMBERS
where MNAME like '%꺽정'
;
select *
from MEMBERS
where MNAME like '%꺽%'
;
select *
from MEMBERS
where MNAME like '임_정'
;
select *
from MEMBERS
where MNAME like '임__'
;
select *
from MEMBERS
where MNAME like '임_'
;
between 연산자 a and b
: x >= a and x <= b 와 같다- 형식
between 값a and 값b
ex>
select *
from MEMBERS
where AGE >= 20 and AGE <= 30
;
select *
from MEMBERS
where AGE between 20 and 30
;
in 연산자
- 형식in (값, 값, 값, ...)
ex>
select *
from MEMBERS
where AGE in (20, 30, 40)
;
select *
from MEMBERS
where AGE not in (30)
;
not에 대해서
ex>select *
from MEMBERS
where not MNAME = '임꺽정'
;
select *
from MEMBERS
where MNAME <> '임꺽정'
;
select *
from MEMBERS
where MNAME != '임꺽정'
;
select *
from MEMBERS
where EMAIL = 'leem@test.com'
;
댓글 없음:
댓글 쓰기