SQL INNER JOIN
Keeps only rows that have a match on BOTH sides — the strictest, most common join type, and usually what people mean by just 'JOIN.'
What & Why
INNER JOIN combines rows only when the join condition matches on both sides. In the Queryflo example, a product.feedback row is returned only when its feature_id matches a row in product.features; plain JOIN means the same thing as INNER JOIN in PostgreSQL.
See How It Works
BUSINESS QUESTION
Product wants feedback rows with known feature metadata.
| id | user_id | feature_id | rating | nps_score | comment | created_at |
|---|---|---|---|---|---|---|
| 1 | 101 | 1 | 5 | 9 | Clear and useful | 2024-01-25 12:15:00+00 |
| 2 | 102 | 2 | 4 | NULL | Export worked well | 2024-02-20 15:40:00+00 |
| 3 | 103 | 1 | 4 | 7 | Helpful setup flow | 2024-03-18 09:05:00+00 |
| 4 | 104 | 3 | 3 | NULL | Needs clearer timing | 2024-04-08 17:30:00+00 |
| id | name | description | team | released_at | deprecated_at |
|---|---|---|---|---|---|
| 1 | Activation Checklist | Guides new users through setup | growth | 2024-01-20 | NULL |
| 2 | CSV Export | Exports report data | platform | 2024-02-14 | NULL |
| 3 | Invite Nudges | Prompts workspace collaboration | growth | 2024-03-05 | NULL |
| 4 | Legacy Dashboard | Original reporting surface | analytics | 2023-08-10 | 2024-06-01 |
Trace the relationship row by row1× speed
product.features
| id | name |
|---|---|
| 1 | Activation Checklist |
| 2 | CSV Export |
| 3 | Invite Nudges |
| 4 | Legacy Dashboard |
feature.id = feedback.feature_id
product.feedback
| id | feature_id | rating | created_at |
|---|---|---|---|
| 1 | 1 | 5 | 2024-01-25 12:15:00+00 |
| 2 | 2 | 4 | 2024-02-20 15:40:00+00 |
| 3 | 1 | 4 | 2024-03-18 09:05:00+00 |
| 4 | 3 | 3 | 2024-04-08 17:30:00+00 |
Result set · 1 rows
| name | rating | created_at |
|---|---|---|
| Activation Checklist | 5 | 2024-01-25 12:15:00+00 |
Feedback 1 matches feature 1.
EXAMPLE QUERY
SELECT
f.name,
fe.rating,
fe.created_at
FROM product.feedback fe
INNER JOIN product.features f ON f.id = fe.feature_id
ORDER BY fe.id;Now You Try
Practice this concept
Product wants feedback rows with their matching feature metadata.
Available schema
productPrefix tables with product.table_name.
nameratingcreated_atproduct.features| Column | Type |
|---|---|
| id | integer |
| name | text |
| description | text |
| team | text |
| released_at | timestamp with time zone |
| deprecated_at | timestamp with time zone |
| internal_priority | integer |
product.feedback| Column | Type |
|---|---|
| id | integer |
| user_id | integer |
| feature_id | integer |
| rating | integer |
| nps_score | integer |
| comment | text |
| created_at | timestamp with time zone |
| moderation_bucket | text |
query.sql
Sign up free to try it on a real business scenario