SQL Basics - Joins

· 6년 전 · 749

Join에 대해서는 별도로 설명..

 

제품을 Join시킨경우

select * from customer.orders
inner join Products on Orders.ProductId=Products.id;

 

as로 긴 네임을 짧게

 

select * from customer.orders as o
inner join Products as p on o.ProductId=p.id;

 

AS도 줄이자..

 

select * from customer.orders o
inner join Products p on o.ProductId=p.id;

 

전체를 볼 필요없이

select o.*, p.*, c.* from customer.orders o
inner join Products p on o.ProductId=p.id
inner join Customer c on o.CustomerID=c.id;

 

필요한 것만 표시하자..

select o.OrderDate, p.ProductName, p.Price, c.* from customer.orders o
inner join Products p on o.ProductId=p.id
inner join Customer c on o.CustomerID=c.id;

 

링크를 클릭하세요

|
댓글을 작성하시려면 로그인이 필요합니다.

그누5튜닝

+
제목 글쓴이 날짜 조회
6년 전 조회 1,273
6년 전 조회 1,252
6년 전 조회 1,380
6년 전 조회 1,349
6년 전 조회 3,268
6년 전 조회 1,462
6년 전 조회 1,473
6년 전 조회 1,497
6년 전 조회 1,073
6년 전 조회 842
6년 전 조회 954
6년 전 조회 1,059
6년 전 조회 1,327
6년 전 조회 900
6년 전 조회 750
6년 전 조회 985
6년 전 조회 797
6년 전 조회 567
6년 전 조회 715
6년 전 조회 662
6년 전 조회 662
6년 전 조회 605
6년 전 조회 1,236
6년 전 조회 1,805
6년 전 조회 1,548
6년 전 조회 806
6년 전 조회 786
6년 전 조회 1,462
6년 전 조회 697
7년 전 조회 891