Login
Register
All Activity
Questions
Unanswered
Tags
Users
Ask a Question
About Us
985
Questions
779
Answers
Interview Preparation mode
beta
Funny Facebook Status
Enter your email address
All categories
SQL Server Interview Questions and Answers
(197)
SSIS Interview Questions and Answers
(54)
SSRS Interview Questions and Answers
(9)
SSAS Interview Questions and Answers
(29)
.NET Interview Questions and Answers
(186)
Oracle Interview Questions and Answers
(122)
Java Interview Questions and Answers
(32)
UNIX Interview Questions and Answers
(47)
Networking Interview Questions and Answers
(17)
MySQL Interview Questions and Answers
(30)
HR Interview Questions and Answers
(236)
General Interview Questions and Answers
(9)
Other Interview Questions and Answers
(8)
Job Openings
(3)
Greenplum Database Interview Questions and Answers
(5)
What are different types of joins in SQL, in MS SQL Server?
Nice?
Vote!
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
–
edited
1 year
ago
by
R
sql-server-interview-question
database
t-sql
joins
1 Answer
Nice?
Vote!
INNER JOIN
-----------------
Inner join shows matches only when they exist in both tables.Example, in the below SQL there are two tables Customers and Orders and the inner join in made on Customers Customerid and Orders Customerid.So this SQL will only give you result with customers who have orders.If the customer does not have order it will not display that record.
SELECT Customers.*,
Orders.*
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID =Orders.CustomerID
LEFT OUTER JOIN
--------------------------
Left join will display all records in left table of the SQL statement.In SQL below customers with or without orders will be displayed. Order data for customers without orders appears as NULL values. For example, you want to determine the amount ordered by each customer and you need to see who has not ordered anything as well. You can also see the LEFT OUTER JOIN as a mirror image of the RIGHT OUTER JOIN (Is covered in the next section) if you switch the side of each table.
SELECT Customers.*,
Orders.*
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.CustomerID =Orders.CustomerID
RIGHT OUTER JOIN
-----------------------------
Right join will display all records in right table of the SQL statement. In SQL below all orders with or without matching customer records will be displayed. Customer data for orders without customers appears as NULL values. For example, you want to determine if there are any orders in the data with undefined CustomerID values (say, after a conversion or something like it). You can also see the RIGHT OUTER JOIN as a mirror image of the LEFT OUTER JOIN if you switch the side of each table.
SELECT Customers.*,
Orders.*
FROM Customers
RIGHT OUTER JOIN Orders
ON Customers.CustomerID =Orders.CustomerID
answered
1 year
ago
by
R
(
19,530
points)
Related questions
Nice?
Vote!
Add
Ans!
What are the different Cursor Types, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql
cursor
Nice?
Vote!
1
answer
What is a self-join, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql
joins
Nice?
Vote!
Add
Ans!
What is “CROSS JOIN”, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql
table
joins
Nice?
Vote!
4
answers
What is Cascade and Restrict in DROP table SQL, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql
table
database
Nice?
Vote!
Add
Ans!
What are RANKING functions, in MS SQL Server?
asked
1 year
ago
in
SQL Server Interview Questions and Answers
by
R
(
19,530
points)
sql-server-interview-question
t-sql