Table Right Join TSQL Tutorial

Right Join Example:

Customers Table

CUSTOMER_IDCUSTOMER_NAMEUSER_NAME
1CUSTOMER_1SYSTEM
2CUSTOMER_2ELLEN
3CUSTOMER_3TOM
4CUSTOMER_4STEVE
5CUSTOMER_5
6CUSTOMER_6

Users Table

USER_NAMEDEPARTMENT_NAME
SYSTEMIT
TOMSALES
STEVESALES
ELLENSALES
JOHNIT

SELECT c.customer_id, c.customer_name, c.user_name
 FROM users u RIGHT JOIN customers c
    ON c.user_name = u.user_name
ORDER BY c.customer_id ;

Result:

Customer_IdCustomer_NameUser_Name
1CUSTOMER_1SYSTEM
2CUSTOMER_2ELLEN
3CUSTOMER_3TOM
4CUSTOMER_4STEVE
5CUSTOMER_5
6CUSTOMER_6