From the course: Querying Microsoft SQL Server 2019

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Return common rows with INTERSECT

Return common rows with INTERSECT - SQL Server Tutorial

From the course: Querying Microsoft SQL Server 2019

Start my 1-month free trial

Return common rows with INTERSECT

- [Instructor] When you want to find rows that are identical between two queries, you can use the INTERSECT operator. Just like EXCEPT and UNION, the INTERSECT operator works between two complete SELECT queries. Let's see how this might be useful by creating a new query that looks at the raw data from the ProductPhoto and ProductReview tables. Both intersects are in the Production schema. The ProductProductPhoto table, which is that we're seeing here at the very top is used to join the products that AdventureWorks carries to the photos used on the website and catalogs through the ProductID column. The second query is against the ProductReview table. Let's go ahead and move this up so I can see it. The ProductReview table also uses the ProductID column to join customer reviews to the specific products. Now, in order to find out if there are any products that have both a photo and a review, we can quickly turn this…

Contents