select * from test;
-> test table의 내용을 전부 가지 온다.
select a, b from test;
-> a, b 컬럼에 대한 내용만 가지고 온다.
select max(a) from test;
-> a 컬럼의 가장 큰 값만 가지고 온다.
select min(a) from test;
-> a 컬럼의 가장 작은 값만 가지고 온다.
select * from test where a>1 and a<10;
-> test 테이블에서 a의 값이 1보다 크고 10보다 작은 값들만 전부 가지고 온다.
select * from test where a=100;
-> test 테이블에서 a가 100인 레코드를 가지고 온다.
select * from test where b='asdf';
-> test 테이블에서 b의 값이 'asdf'인 레코드를 전부 가지고 온다.
select * from test where b like '%z';
-> test 테이블에서 b의 값이 z로 끝나는 레코드를 전부 가지고 온다.
select * from test where b like '%a';
-> test 테이블에서 b의 값이 a로 시작하는 레코드를 전부 가지고 온다.
select * from test where b like '%asdf%';
-> test 테이블에서 b의 값에 asdf가 포함된 레코드를 전부 가지고 온다.
select and order by
select * from test_tbl order by A asc
-> test_tbl 테이블값을 A 기준으로 오름차순으로 가지고 온다.
select * from test_tbl order by A desc
-> test_tbl 테이블값을 A 기준으로 내림차순으로 가지고 온다.
'03.웹' 카테고리의 다른 글
| [HTML5] 개발툴 Liveweave (0) | 2017.02.24 | 
|---|---|
| [Tomcat] server.xml 위치 (0) | 2016.12.28 | 
| [MariaDB] 리눅스에서 DB 경로 확인 (0) | 2016.12.26 | 
| [MariaDB] [Workbench] Error Code: 1046. No database selected Select the default DB to be used by double-clicking its name in the SCHEMAS list in the sidebar (0) | 2016.12.22 | 
| [Node.js] 설치 (0) | 2016.07.22 |