<-- Chapter 25: SQL Join
Chapter 26
SQL Inner Join
SQL Inner Join clause is used to fetch all the rows from more than two tables in which there is a match between the columns. Inner Join is similar like Join clause.
Lets see an examples from the below tables "customers" :-
customer_id |
name |
country |
1 |
abc |
India |
2 |
def |
Australia |
3 |
ghi |
USA |
4 |
jkl |
India |
5 |
mno |
Bangladesh |
Lets see an examples from the below tables "orders" :-
date
|
customer_id
|
amount
|
30-11-2015 |
2 |
3000 |
30-11-2015 |
1 |
1500 |
31-12-2015 |
1 |
2000 |
31-12-2015 |
3 |
2000 |
SQL JOIN SQL syntax :-
SELECT `customers`.`name` AS [Customer Name], `orders`.`date` AS `Date`
FROM `orders`
INNER JOIN `customers`
ON `orders`.`customer_id` = `customers`.`customer_id`;
Now run the above SQL query, we will see the output below :-
Customer Name |
Date |
def |
30-11-2015 |
abc |
30-11-2015 |
abc |
31-12-2015 |
ghi |
31-12-2015 |
Now we can see here, we have displayed customer name and order date of customer on the basis of common customer_id between customers and orders tables.
Chapter 27: SQL Left Join -->
0 Comment(s)