I got your doubt, Checkout these queries I hope this will help you out,
Suppose we have two tables:
If we use 'Union' that time it will return all the distinct value from both of the table
SELECT City FROM Customers
SELECT City FROM Suppliers
ORDER BY City;
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.