Intersect:The intersect statement is used to fetch the common records between the tables. Here we have two tables. Both tables have similar kinds of records.
CREATE TABLE ProductStock
(
ProductId INT PRIMARY KEY IDENTITY(1,1),
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
StockQty BIGINT,
LastUpdated date
)
Go
CREATE TABLE ProductOrder
(
OrderId INT PRIMARY KEY IDENTITY(1,1),
ProductId int,
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
OrderQty BIGINT,
OrderDate date
)
ProductStock :
ProductOrder:
INTERSECT QUERY :
SELECT ProductId,ProductName,ManufacturedBy FROM ProductStock
INTERSECT
SELECT ProductId,ProductName,ManufacturedBy FROM ProductOrder
Result :
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Intersect: The intersect statement is used to fetch the common records between the tables. Here we have two tables. Both tables have similar kinds of records.
CREATE TABLE ProductStock
(
ProductId INT PRIMARY KEY IDENTITY(1,1),
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
StockQty BIGINT,
LastUpdated date
)
Go
CREATE TABLE ProductOrder
(
OrderId INT PRIMARY KEY IDENTITY(1,1),
ProductId int,
ProductName VARCHAR(100),
ManufacturedBy VARCHAR(100),
OrderQty BIGINT,
OrderDate date
)
ProductStock :


ProductOrder:
INTERSECT QUERY :
SELECT ProductId,ProductName,ManufacturedBy FROM ProductStock
INTERSECT
SELECT ProductId,ProductName,ManufacturedBy FROM ProductOrder