Database
2003.04.23 09:46

[sql] 간단한 SQL 문법 정리

Views 14045 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
* 특정 필드 검색
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
No. Category Subject Author Date Views
41 Database [mysql] DB->Text, Text->DB 변환 hooni 2003.04.23 13411
40 System/OS HTTP 프로토콜 (브라우저와 웹서버 간의 통신) hooni 2003.04.23 50772
39 System/OS [linux] 센드메일 동적릴레이 설치 hooni 2003.04.23 16461
38 System/OS [linux] 데스크탑환경(GNOME/KDE) 바꾸기.. hooni 2003.04.23 13254
37 System/OS [linux] 웹로그분석기(webalizer) 설치 & 팁 hooni 2003.04.23 16009
36 System/OS [linux] 메일서버 세팅정보(sendmail) hooni 2003.04.23 18646
35 System/OS [linux] APM(apache, php, mysql) + gd 설치순서.. hooni 2003.04.23 20061
34 System/OS [linux] 쉘 환경변수 PS1(프롬프트) hooni 2003.04.23 14607
33 Database [mysql] 쓰레드가 계속 쌓이기 시작하고 사라지지 않을때.. hooni 2003.04.23 13999
32 System/OS [linux] 콘솔/Xwindow 에서 PC스피커 소리 없애기 hooni 2003.04.23 17503
31 Develop [c] 프로그래밍 ppt, 스킬업 (비트 수업자료) file hooni 2003.04.23 9440
30 Develop [c++] p.118 확인학습 5번 hooni 2003.04.23 11934
29 Develop [c++] p.58 연습문제 2번 hooni 2003.04.23 17406
28 Develop [c++] p.47 연습문제 3번 hooni 2003.04.23 11325
27 Develop [opengl] 컴퓨터 그래픽스 강의 자료(수업자료) file hooni 2003.04.23 22046
26 Develop [c] 그래픽스 자료(OpenGL 라이브러리) 샘플 소스 file hooni 2003.04.23 11325
Board Pagination Prev 1 ... 70 71 72 73 74 Next
/ 74