rightjoin

SQL RIGHT JOIN

SQL RIGHT JOIN

The RIGHT JOIN clause returns all rows from the right table and the matched rows from the left table. If no match is found, the result is NULL on the left side.

Example of RIGHT JOIN

SELECT Users.first_name, Users.last_name, Orders.order_date
FROM Users
RIGHT JOIN Orders ON Users.user_id = Orders.user_id;
    

This query retrieves the first and last names of users (if available) and their order dates, ensuring that every order is listed even if the user does not exist.