Tags

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


T-SQL Output Query | [ The JOIN Puzzle – Part 1 ]

Please go through the queries and the sample input data and provide the outputs of the query given below.

–Let’s say we have 2 table TestJoinsT1 and TestJoinsT2. Both the tables having only one ID column. Here you have to provide the output of the queries given below

1

2


--Please go through the data given above and provide outputs for below queries

--Query 1
SELECT t1.ID , t2.ID
FROM [dbo].[TestJoinsT1] t1 INNER JOIN [dbo].[TestJoinsT2] t2 
ON t1.ID = t2.ID

--Query 2
SELECT t1.ID , t2.ID
FROM [dbo].[TestJoinsT1] t1 LEFT OUTER JOIN [dbo].[TestJoinsT2] t2 
ON t1.ID = t2.ID

--Query 3
SELECT t1.ID , t2.ID
FROM [dbo].[TestJoinsT1] t1 RIGHT OUTER JOIN [dbo].[TestJoinsT2] t2 
ON t1.ID = t2.ID

--Query 4
SELECT t1.ID , t2.ID
FROM [dbo].[TestJoinsT1] t1 FULL OUTER JOIN [dbo].[TestJoinsT2] t2 
ON t1.ID = t2.ID

Please leave a comment if you need solution to the above puzzle

Keep Learning

Advertisements