MYSQL-where 문
|
|
where 우리나라 말로 '어디' 입니다.
select,delete, update 에서 조건에 맞는 레코드를 지정하고자 할 때 사용되는 구문입니다.
|
|
아래는 연습용 테이블 member 입니다.
name |
id |
pw |
birthday |
김마이 |
my |
apple |
0525 |
이에스 |
s |
banana |
0313 |
박큐엘 |
ql |
orange |
0222 |
where 필드명 = 검색어
ex) select * from member where name = '김마이'
name필드가 김마이인 레코드가 검색됨
where 필드명 = 검색어 or 검색어
ex) select * from member where birthday = birthday >0200
->and birthday < 0400
where 필드명 = 검색어 and 검색어
ex) select * from member where birthday = birthday >0200
→ and birthday < 0400
birthday필드가 200보다 크고 400 보다 작은 레코드가 검색됨
where 필드명 between 검색어 and 검색어
ex) select * from member where birthday between 200 and 400
birthday필드가 200보다 크고 400 보다 작은 레코드가 검색됨
where 필드명 like ('검색어%')
ex) select * from member where birthday like ('02%')
02로 시작하는 모든 단어가 검색됩니다.
where 필드명 like ('_검색어')
ex) select * from member where birthday like ('__2')
세번째 글자가 2인 단어만 검색합니다.
where 필드명 like ('_검색어%')
ex) select * from member where birthday like ('__2%')
세번째 글자가 2를 포함하는 단어룰 모두 검색됩니다.
where 필드명 IN ('apple', 'banana')
ex) select * from member where birthday IN ('apple','banana')
필드명이 apple이거나 banana 인걸 검색해요