Contents

Database
2003.04.23 09:46

[sql] 간단한 SQL 문법 정리

조회 수 14045 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
* 특정 필드 검색
select  필드명  from  테이블명  where  필드='값';
예) select  post_no  from  post  where  post_no = '530-360';


* 중복 필드 제거(distinct)
select  distinct(names)  as  d_names  from  picomax_addr;


*where문 - 조건

- 아닌것만 검사 (<>)
select  *  from  picomax_addr  where  names <>  '테스트';

- null 만 검사
select  *  from  picomax_addr  where  names  is  null;

- 영역 검사 (between)
select  *  from  post  where  post_no  between  '530-360' and '530-390';

- 영역내 검사 (in)
select  *  from  picomax_addr  where  names  names  in('테스트','홍길동');

- 패턴매칭 검사(like)
select  post_no  from  post  where  post_no  like '530-3%';
select  post_no  from  post  where  post_no  like '530-3_0';
select  post_no  from  post  where  post_no  like '530-3__';

- 부정 검사(not)
select  *  from  picomax_addr  where  names is not null;

- 조건연산자(and, or)
select  *  from  picomax_addr  where  names='테스트' and  telno='000-0000';

- 검색결과의 정렬(order by)
select  *  from  picomax_addr  order  by  telno  ASC;
select  *  from  picomax_addr  order  by  telno  DESC;

- 합계 (sum)
select  sum(점수)  from  학점;
select  sum(점수)  as  총점  from  학점;

- 평균 (avg)
select  avg(점수)  from  학점;

- 최소값 (min)
select  min(점수)  from  학점;

- 최대값(max)
select  max(점수)  from  학점;

* group by 문
select  과목, count(*)  from  학점  group  by  과목;

?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
1021 Etc 캘리포니아 운전면허 문제 file hooni 2017.07.22 3484
1020 Develop [ios] Objective-C 에서 자주 사용하는 수학 함수와 유용한 Define hooni 2014.08.08 3502
1019 Develop [java] netty (비동기 이벤트 방식 네트워크 프레임워크) 사용법 #2 (client) hooni 2015.01.02 3533
1018 System/OS 맥 OS X 에서 스크린 화면 캡쳐 단축키 (Mac Print Screen) hooni 2015.07.21 3560
1017 Develop [android] SQLiteOpenHelper를 이용한 DBManager hooni 2017.06.14 3564
1016 Develop [ios] 설정에서 푸시 알림(APNS) on/off 상태 확인 hooni 2015.04.28 3581
1015 System/OS iptime 공유기 해킹 기술문서 4 file hooni 2015.01.01 3621
1014 System/OS [linux] The Ultimate Wget Download Guide With 15 Awesome Examples hooni 2020.05.26 3630
1013 Develop [ios] XCode에서 Provisioning Profile 여러개 중복될 때 hooni 2014.06.26 3676
1012 Develop [python][django] request.cookie 읽어오기 ㅋㅋㅋ (쓰기) hooni 2019.12.06 3680
1011 PPT [ppt] Information Security 발표 자료 (@Team Study 2012.11.15) file hooni 2015.07.22 3703
1010 Etc ISMS 인증기준 – 정보보호대책 (시스템개발보안) file hooni 2016.12.01 3712
Board Pagination Prev 1 ... 9 10 11 12 13 14 15 16 17 18 ... 99 Next
/ 99