Inner Join Example:
Customers Table
CUSTOMER_ID | CUSTOMER_NAME | CUSTOMER_TYPE |
1 | CUSTOMER_1 | CC |
2 | CUSTOMER_2 | I |
3 | CUSTOMER_3 | SM |
4 | CUSTOMER_4 | CC |
Contracts Table
CONTRACT_ID | CUSTOMER_ID | AMOUNT |
1 | 1 | 400 |
2 | 2 | 500 |
3 | 3 | 700 |
4 | 1 | 1000 |
5 | 2 | 1200 |
6 | 4 | 900 |
7 | 3 | 2000 |
8 | 2 | 1500 |
SELECT c.customer_id, c.customer_name, ctr.contract_id, ctr.amount
FROM customers c, contracts ctr
WHERE c.customer_id = ctr.customer_id
AND ctr.amount > 900 ;
Result:
Customer_Id | Customer_Name | Contract_Id | Amount |
1 | CUSTOMER_1 | 4 | 1000 |
2 | CUSTOMER_2 | 8 | 1500 |
2 | CUSTOMER_2 | 5 | 1200 |
3 | CUSTOMER_3 | 7 | 2000 |