Can you explain what is the difference between UNION and Join?

0 votes
I have a doubt regarding union and join operation?

can you please explain with example?
May 30 in Database by Sahana
24 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Hi Sahana, 

I got your doubt, Checkout these queries I hope this will help you out,

Suppose we have two tables:

1.Customers 

2.City

If we use 'Union' that time it will return all the distinct value from both of the table

SELECT City FROM Customers
UNION
SELECT City FROM Suppliers
ORDER BY City;

Join:

Here is the list of joins we can do to manipulate the data.

1. Inner join

2. Right join

3. Left join

4. Full outer join 

5. Self join

1.Inner join: INNER JOIN  selects records that have matching values in both tables.

2. Right join: RIGHT JOIN returns all records from the right table (table2), and the matched records from the left table (table1)

3.Left join:  LEFT JOIN keyword returns all records from the left table (table1), and the matched records from the right table (table2)

4. Full outer join: FULL OUTER JOIN return all records when there is a match in either left (table1) or right (table2) table records

5. Self join:  self JOIN is a regular join, But the table is joined with itself.

Thank you,

answered May 30 by Sampriti
• 620 points

Related Questions In Database

0 votes
1 answer

Difference between cross join and natural join

The cross join produces the cross product ...READ MORE

answered Oct 12, 2018 in Database by DataKing99
• 8,100 points
933 views
+1 vote
1 answer

What is the AND operator?

The AND operator is used to filter ...READ MORE

answered Nov 30, 2018 in Database by darklord
• 6,140 points
42 views
0 votes
1 answer

What is MSLAB and LZO?

MSLAB stands for Memstore-Local Allocation Buffer. Lempel-Ziv-Oberhumer (LZO) ...READ MORE

answered Jul 10, 2018 in Database by Data_Nerd
• 2,340 points
58 views
0 votes
1 answer

Difference between Inner Join & Outer Join

The difference is as follows: INNER JOIN: Returns all those ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,100 points
45 views
0 votes
1 answer

Do I need to add primary key in each and every table?

Hi Shraddha, You have a doubt to add ...READ MORE

answered May 29 in Database by Sampriti
• 620 points
18 views
0 votes
1 answer

How to sort the data in sql ?

Hi Akash,  If you want to sort ...READ MORE

answered May 29 in Database by Sampriti
• 620 points
8 views
0 votes
1 answer

Want a command to be executed in Salt only if a directory is empty

You should consider using this inside your ...READ MORE

answered Jun 12, 2018 in DevOps Tools by Damon Salvatore
• 5,450 points
30 views
0 votes
1 answer

Can you please explain the difference between inner join and outer join in database?

Hi Suraj, You have a doubt regarding inner join ...READ MORE

answered May 28 in Database by Sampriti
• 620 points
19 views
0 votes
1 answer

What is the best way to fetch data from table?

Hey Shraddha, I understand your doubts about fetching ...READ MORE

answered May 24 in Database by Sampriti
• 620 points
14 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.