티스토리 뷰
mysql join 실습 예제
MariaDB [opentutorials]> select * from topic;
+----+------------+------------------+---------------------+-----------+
| id | title | description | created | author_id |
+----+------------+------------------+---------------------+-----------+
| 1 | my sql | mysql is... | 2018-09-22 00:12:27 | 1 |
| 2 | oracle | oracle is... | 2018-09-22 00:13:38 | 1 |
| 3 | sql server | sql server is... | 2018-09-22 00:14:37 | 2 |
| 4 | postgresql | postgresql is... | 2018-09-22 00:17:48 | 3 |
| 5 | mongodb | mongodb is... | 2018-09-22 00:18:51 | 1 |
+----+------------+------------------+---------------------+-----------+
5 rows in set (0.00 sec)
MariaDB [opentutorials]> select * from author;
+----+--------+---------------------------+
| id | name | profile |
+----+--------+---------------------------+
| 1 | egoing | developer |
| 2 | duru | data administrator |
| 3 | taeho | data scientist, developer |
+----+--------+---------------------------+
3 rows in set (0.00 sec)
MariaDB [opentutorials]> select * from topic left join author on topic.author_id = author.id;
+----+------------+------------------+---------------------+-----------+------+--------+---------------------------+
| id | title | description | created | author_id | id | name | profile |
+----+------------+------------------+---------------------+-----------+------+--------+---------------------------+
| 1 | my sql | mysql is... | 2018-09-22 00:12:27 | 1 | 1 | egoing | developer |
| 2 | oracle | oracle is... | 2018-09-22 00:13:38 | 1 | 1 | egoing | developer |
| 3 | sql server | sql server is... | 2018-09-22 00:14:37 | 2 | 2 | duru | data administrator |
| 4 | postgresql | postgresql is... | 2018-09-22 00:17:48 | 3 | 3 | taeho | data scientist, developer |
| 5 | mongodb | mongodb is... | 2018-09-22 00:18:51 | 1 | 1 | egoing | developer |
+----+------------+------------------+---------------------+-----------+------+--------+---------------------------+
5 rows in set (0.01 sec)
'프로그래밍 > C#' 카테고리의 다른 글
윈도우에 MySQL설치하기 (0) | 2018.09.25 |
---|---|
맥(mysqlworkbench)를 이용해 라즈베리파이 mysql 원격제어 (0) | 2018.09.22 |
mysql 테이블 분리하기 (0) | 2018.09.22 |
mysql delete문 실습 (0) | 2018.09.21 |
mysql update 문 실습 (0) | 2018.09.21 |