PostgreSQL — Joins
Inner Join
SELECT users.name, orders.total
FROM users
INNER JOIN orders ON users.id = orders.user_id;
Left Join
SELECT users.name, orders.total
FROM users
LEFT JOIN orders ON users.id = orders.user_id;
Right Join
SELECT users.name, orders.total
FROM users
RIGHT JOIN orders ON users.id = orders.user_id;
Full Outer Join
SELECT users.name, orders.total
FROM users
FULL OUTER JOIN orders ON users.id = orders.user_id;
Cross Join
SELECT users.name, products.name
FROM users
CROSS JOIN products;
Join Types
| Type | Description |
|---|---|
| INNER | Matching rows only |
| LEFT | All left, matching right |
| RIGHT | All right, matching left |
| FULL | All rows from both |
| CROSS | Cartesian product |
Mini Practice
- Use inner join
- Use left join
- Use right join
- Use full outer join
Up Next
Continue with Inner Join — inner join details.
Related Topics
Frequently Asked Questions about Joins
What is Joins in PostgreSQL?
Joins is a fundamental concept in PostgreSQL. This lesson explains it step by step with clear examples, making it easy for beginners to understand.
How do I learn Joins?
Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Joins.
Why is Joins important in PostgreSQL?
Joins is essential for PostgreSQL development. Understanding this concept will help you write better code and solve real-world problems more effectively.