티스토리 뷰
mysql select문 실습
전체보기: select *
MariaDB [opentutorials]> select * from topic
-> ;
+----+------------+------------------+---------------------+--------+-------------------------+
| id | title | description | created | author | profile |
+----+------------+------------------+---------------------+--------+-------------------------+
| 1 | mysql | mysql is... | 2018-09-21 21:26:22 | egoing | developer |
| 2 | orcle | orcle is.. | 2018-09-21 21:30:37 | egoing | devloper |
| 3 | sql server | sql server is... | 2018-09-21 21:32:08 | duru | data administator |
| 4 | postsql | postsql is... | 2018-09-21 21:36:45 | taeho | data scientist devloper |
| 5 | mongodb | mongdb is.. | 2018-09-21 21:37:55 | egoing | devloper |
+----+------------+------------------+---------------------+--------+-------------------------+
보고싶은것만 보기: select 보고싶은것
만약 id, title, created, author 만 보고 싶다면
ariaDB [opentutorials]> select id, title, created, author from topic;
+----+------------+---------------------+--------+
| id | title | created | author |
+----+------------+---------------------+--------+
| 1 | mysql | 2018-09-21 21:26:22 | egoing |
| 2 | orcle | 2018-09-21 21:30:37 | egoing |
| 3 | sql server | 2018-09-21 21:32:08 | duru |
| 4 | postsql | 2018-09-21 21:36:45 | taeho |
| 5 | mongodb | 2018-09-21 21:37:55 | egoing |
+----+------------+---------------------+--------+
5 rows in set (0.01 sec)
MariaDB [opentutorials]> select "egoing", 1+1;
+--------+-----+
| egoing | 1+1 |
+--------+-----+
| egoing | 2 |
+--------+-----+
1 row in set (0.01 sec)
MariaDB [opentutorials]> select id, title, created, author from topic where author='egoing';
+----+---------+---------------------+--------+
| id | title | created | author |
+----+---------+---------------------+--------+
| 1 | mysql | 2018-09-21 21:26:22 | egoing |
| 2 | orcle | 2018-09-21 21:30:37 | egoing |
| 5 | mongodb | 2018-09-21 21:37:55 | egoing |
+----+---------+---------------------+--------+
3 rows in set (0.01 sec)
desc => 내림차순
MariaDB [opentutorials]> select id, title, created, author from topic where author='egoing' order by id desc;
+----+---------+---------------------+--------+
| id | title | created | author |
+----+---------+---------------------+--------+
| 5 | mongodb | 2018-09-21 21:37:55 | egoing |
| 2 | orcle | 2018-09-21 21:30:37 | egoing |
| 1 | mysql | 2018-09-21 21:26:22 | egoing |
+----+---------+---------------------+--------+
3 rows in set (0.00 sec)
limit => 제한적으로 출력
MariaDB [opentutorials]> select id, title, created, author from topic where author='egoing' order by id desc limit 2;
+----+---------+---------------------+--------+
| id | title | created | author |
+----+---------+---------------------+--------+
| 5 | mongodb | 2018-09-21 21:37:55 | egoing |
| 2 | orcle | 2018-09-21 21:30:37 | egoing |
+----+---------+---------------------+--------+
2 rows in set (0.00 sec)
'프로그래밍 > C#' 카테고리의 다른 글
mysql delete문 실습 (0) | 2018.09.21 |
---|---|
mysql update 문 실습 (0) | 2018.09.21 |
mysql 테이블 insert 실습 (0) | 2018.09.21 |
mysql 테이블 생성하기 (0) | 2018.09.21 |
mysql 데이터베이스 생성 기본명령어 (0) | 2018.09.21 |