T-SQL Tutorial

T-SQL Table Inner Join


Inner Join Example:

Customers Table

CUSTOMER_IDCUSTOMER_NAMECUSTOMER_TYPE
1CUSTOMER_1CC
2CUSTOMER_2I
3CUSTOMER_3SM
4CUSTOMER_4CC

Contracts Table

CONTRACT_IDCUSTOMER_IDAMOUNT
11400
22500
33700
411000
521200
64900
732000
821500

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_IdCustomer_NameContract_IdAmount
1CUSTOMER_141000
2CUSTOMER_281500
2CUSTOMER_251200
3CUSTOMER_372000