SQL에서 사용할 수 있는 기본적인 문법을 간단하게 소개해보도록 하겠습니다.
SELECT 쿼리문
select 필드이름 from 테이블
SELECT 전체 필드 조회
SELECT * FROM 테이블
AND 조건문
select * from 테이블
where 필드이름1 = "원하는 값1" and 필드이름2 = "원하는 값2";
같지 않음 조건문
select * from 테이블
where 필드이름 != "원하지 않는 값";
범위 조건문
select * from 테이블
where 필드이름 between "2020-07-13" and "2020-07-15";
select * from 테이블
where 필드이름 not between "2020-07-13" and "2020-07-15";
포함 / 불포함 조건문
select * from 테이블
where 필드이름 in (1, 3);
select * from 테이블
where 필드이름 not in (1, 3);
패턴(문자열 규칙) 조건문
select * from 테이블
where 필드이름 like '%daum.net';
select * from 테이블
where 필드이름 not like '%daum.net';
limit : 일부 데이터만 가져오기
select * from 테이블
where 필드이름 = "원하는값"
limit 5;
Distinct : 중복 데이터 제외
select distinct(필드이름) from 테이블;
Count : 데이터 숫자 카운트
select count(*) from 테이블
728x90
반응형
'Programming > SQL' 카테고리의 다른 글
[SQL] SQL 기초 개념 정리 (0) | 2022.04.06 |
---|
댓글