What is the difference between INNER JOIN and INTERSECT? Can anyone exemplify it too?
What is the difference between INNER JOIN and INTERSECT? Can anyone exemplify it too?
INTERSECT and EXCEPT operations are performed based on the implicit conversion of the result between two queries.
INNER JOIN operations link two tables or queries through one or more fields.
<query_specification> | ( <query_expression> )
EXCEPT | INTERSECT
<query_specification> | ( <query_expression> )
-- Uses AdventureWorks
SELECT ProductID
FROM Production.Product
INTERSECT
SELECT ProductID
FROM Production.WorkOrder ;
--Resultado: 238 linhas (produtos que tem WorkOrder)
Following is the Microsoft documentation reference. EXCEPT and INTERSECT