SQL 내부 조인

(INNER JOIN에서 넘어옴)

1 개요[ | ]

SQL inner join
SQL 내부 조인

2 예시 1: employee & department[ | ]

SELECT * FROM employee
SELECT * FROM department
SELECT * FROM employee JOIN department
ON employee.DepartmentID = department.DepartmentID
SELECT A.LastName, B.*
FROM employee A JOIN department B
ON A.DepartmentID = B.DepartmentID

3 예시 2: Sales & Countries[ | ]

Inner-join-operation.png

CREATE TABLE Sales (Date date, CountryID int(11), Units int(11));
INSERT INTO Sales (Date, CountryID, Units) VALUES
	('2020-01-01', 1, 40),
	('2020-01-02', 1, 25),
	('2020-01-03', 3, 30),
	('2020-01-04', 2, 35);

CREATE TABLE Countries (ID int(11), Country varchar(16));
INSERT INTO Countries (ID, Country) VALUES
	(3, 'Panama'),
	(4, 'Spain');

SELECT Sales.*, Countries.Country
FROM Sales JOIN Countries
ON Sales.CountryID = Countries.ID

4 같이 보기[ | ]

5 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}