INTERSECT Example | SQL Statements | Teradata Vantage - 17.05 - Example - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)

Assume that two tables contain the following rows:

SPart table   SLocation table
SuppNo PartNo   SuppNo SuppLoc
100 P2   100 London
101 P1   101 London
102 P1   102 Toronto
103 P2   103 Tokyo

To then select supplier number (SuppNo) for suppliers located in London (SuppLoc) who supply part number P1 (PartNo), use the following request:

   SELECT SuppNo FROM SLocation 
   WHERE SuppLoc = 'London' 
   INTERSECT 
   SELECT SuppNo FROM SPart 
   WHERE PartNo = 'P1';

The result of this request is:

   SuppNo
   ------
      101