Database/MSSQL work
union, union all, intersect, except
웨이칭
2020. 11. 10. 18:06
--UNION 연산자 (컬럼의 갯수만 맞으면 됨)
select C.custId, C.custName, G.goodsName
from customersTbl C
inner join salesTbl S ON C.custId = S.custId
inner join goodsTbl G On S.goodsId = g.goodsId
where C.custId='kkkkkkkk'
--union
--union all
--union all은 중복데이터를 걸러주지 않음
--intersect
--intersect는 교집합을 의미(inner)
--except
--except는 차집합을 의미한다(outer)
select C.custId, C.custName, G.goodsName
from customersTbl C
inner join salesTbl S ON C.custId = S.custId
inner join goodsTbl G ON S.goodsId = G.goodsId
where G.goodsName = '몽쉘';