Skip to main content
📚 College Credit Guide ✓ UPI Study 🕐 11 min read

SQL joins explained with one example table

This article shows SQL joins with one shared customers-and-orders example so you can compare INNER, LEFT, RIGHT, and FULL OUTER JOIN side by side.

YS
Economist · EdTech Sector Analyst
📅 November 06, 2026
📖 11 min read
YS
About the Author
Yana is completing a PhD in economics. Before academia she worked at investment firms as a sector analyst, with coverage that included edtech companies, services aimed at college students, and the adult-learner market. She interned at UPI Study once and now writes here part-time, applying the same analytical lens she brought to her research to questions students actually face.
🦉

SQL joins connect rows from two tables using a shared column, usually an ID, and the result changes based on which rows match. That sounds simple until you see it in action. A common student mistake is thinking a join permanently combines tables or only keeps exact matches. It does neither. A join returns a result set for one query, and unmatched rows can still matter a lot. Here is the cleanest way to learn sql joins explained: use one tiny customers table and one tiny orders table, then run the same join four ways. You will see how sql join types change the rows you get back. The difference between inner join vs left join becomes obvious fast when one customer has no order and one order has no customer. That matters because the ON clause does not just “connect tables.” It tells SQL which rows count as a match. Change the join type, and you change which unmatched rows survive. Some databases also handle RIGHT JOIN or FULL OUTER JOIN differently, and syntax can vary by SQL dialect, so the exact query shape may shift even when the logic stays the same.

Advanced Technical Writing
College credit · ACE & NCCRS reviewed · self-paced
View course
Artistic close-up of an open hardcover book in soft lighting, highlighting the texture of the pages — UPI Study

What SQL joins example table should you use?

Use one customers table and one orders table with 3 customer rows and 3 order rows, because that setup shows matches, missing matches, and NULLs without noise. In this sql joins example table, customer 1 can match 2 orders, customer 2 can match 0, and order 103 can belong to no customer. That small gap is the whole lesson. Joins do not merge tables forever, and they do not only match identical rows. They return one result set for one query, and missing matches change what you see.

<table class="sample-table"><thead><tr><th>customers</th><th>customer_id</th><th>name</th></tr></thead><tbody><tr><td>row 1</td><td>1</td><td>Ana</td></tr><tr><td>row 2</td><td>2</td><td>Ben</td></tr><tr><td>row 3</td><td>3</td><td>Chen</td></tr></tbody></table> <table class="sample-table"><thead><tr><th>orders</th><th>order_id</th><th>customer_id</th></tr></thead><tbody><tr><td>row 1</td><td>101</td><td>1</td></tr><tr><td>row 2</td><td>102</td><td>1</td></tr><tr><td>row 3</td><td>103</td><td>4</td></tr></tbody></table>

How do SQL joins work in plain language?

A join looks at two tables, checks one shared column, and keeps rows that match that rule. In this example, customers.customer_id matches orders.customer_id, so SQL can pair Ana with order 101 and order 102, but not Chen with order 103 because 3 does not equal 4. The ON clause is the matching rule, and it matters more than most beginners expect. Miss that line, and the query can return a messy cross match instead of a clean 1-to-1 or 1-to-many result.

INNER JOIN keeps only rows where both tables have a match. LEFT JOIN keeps every row from the left table, then fills missing right-side values with NULL. RIGHT JOIN does the same thing from the other side, which means it keeps every row from the right table. FULL OUTER JOIN keeps every row from both tables, matched where possible and padded with NULL where not. That is why the same 3-row sample can produce 2 rows, 3 rows, 4 rows, or 5 rows depending on the join.

The part people mix up: a join does not change the original tables, and it does not “combine” them in storage. It only shapes the output of one query. If you want practice that sticks, run the same SELECT with INNER JOIN, then LEFT JOIN, then RIGHT JOIN, then FULL OUTER JOIN, and watch the row count shift from 2 to 5.

A good next step is to pair this with Database Fundamentals or Database Programming if you want more hands-on query work.

Which SQL join types return which rows?

This comparison shows the same 3 customers and 3 orders from one sample set, so you can see which rows survive each join. The exact syntax can vary by SQL dialect, and some systems handle RIGHT JOIN or FULL OUTER JOIN differently, so test the query in your database before you rely on it. The logic stays stable even when the wording shifts.

Join typeWhat it returnsWhen to use it
INNER JOINAna-101, Ana-102Only matched rows
LEFT JOINAna-101, Ana-102, Ben-NULL, Chen-NULLKeep all customers
RIGHT JOINAna-101, Ana-102, NULL-103Keep all orders
FULL OUTER JOINAna-101, Ana-102, Ben-NULL, Chen-NULL, NULL-103See every row

The table makes the tradeoff plain. INNER JOIN trims the result to matches only, while FULL OUTER JOIN shows the whole picture, even when one side has gaps.

Technical Writing Course UPI Study Dedicated Resource

The Complete Resource for SQL Joins

UPI Study has a full resource page built specifically for sql joins — covering which courses count and how to get started at $250 per course with no deadlines. Your college decides how credits transfer.

Explore on UPI Study →

How does each join change the results?

The easiest way to learn joins is to run the same query pattern four times and compare the row count, not the syntax noise. One shared table set can teach all four joins in under 10 minutes if you keep the columns the same.

  1. INNER JOIN returns only the matches: Ana with orders 101 and 102. SELECT * FROM customers INNER JOIN orders ON customers.customer_id = orders.customer_id;
  2. LEFT JOIN keeps all 3 customers, so Ben and Chen stay even though they have 0 orders. That extra NULL column is the point, not a bug.
  3. RIGHT JOIN keeps all 3 orders, so order 103 remains visible even with no customer match. Some teams avoid it because LEFT JOIN reads more naturally.
  4. FULL OUTER JOIN keeps all 3 customers and all 3 orders, which gives you 5 result rows here. It is the broadest view, but not every database treats it the same way.
  5. Swap the join type, rerun the query, and compare row counts before you change anything else. That habit catches logic mistakes faster than staring at 1 query for 20 minutes.

Reality check: A LEFT JOIN can still return 0 matched rows on the right, and that is normal. The NULLs tell you which records need follow-up, which is often the real reason you use joins in the first place.

What join mistakes should beginners avoid?

The biggest mistake is forgetting the ON clause and accidentally matching every row to every row. On a 3-by-3 example, that can jump you from 2 rows to 9 rows, which looks impressive for 5 seconds and wrong for the rest of the day. The next mistake is using the wrong key, like joining customer_id to order_id, because the numbers may look similar but the meaning is not.

NULL also trips people up. NULL does not mean an empty string, and it does not mean 0. In a LEFT JOIN, a missing match shows up as NULL, so Ben’s missing order is not the same thing as a blank text field. That difference matters when you filter results with WHERE clauses, because a condition like WHERE orders.customer_id = 1 can erase rows you meant to keep.

Worth knowing: RIGHT JOIN and FULL OUTER JOIN do not behave the same way in every SQL dialect, and some systems support 1 but not the other. SQL Server, PostgreSQL, and Oracle usually handle more join types than some lighter tools, but syntax still varies enough to trip people up.

Join order can also fool you. Switching table order can change the meaning of LEFT JOIN and RIGHT JOIN, but it does not change INNER JOIN in the same way. That tiny detail causes a lot of 1-line bugs.

Why should you practice SQL joins next?

Joins click fastest when you practice with one 3-row table pair and then change only 1 thing at a time. That method beats memorizing 4 definitions because your eyes learn what 2 rows, 3 rows, and 5 rows look like in real output. If you want a quick drill, write your own customers and orders tables with 1 missing match on each side, then predict the result before you run the query.

Bottom line: Once you can explain why INNER JOIN returns 2 rows and FULL OUTER JOIN returns 5 rows in the same example, you understand the core idea. For more structured writing and tech practice, explore Advanced Technical Writing.

How does UPI Study fit?

A 1-table SQL drill can turn into real study material fast when you need a repeatable practice set, and that is where a course library with 90+ options helps. UPI Study offers college-level courses that carry a college credit recommendation from NCCRS or ACE, and ACE and NCCRS have over 2,100 cooperating colleges that will consider accepting credits; the final decision is with the universities.

UPI Study also keeps the setup simple: $250 per course or $99 per month for unlimited access, with no deadlines and full self-paced pacing. That mix fits students who want to review joins, query structure, and technical writing without racing a fixed calendar. A course like Advanced Technical Writing can help if you want more practice turning technical ideas into clean explanations.

Good fit: The strength here is repetition, not flash. UPI Study works best for learners who want steady practice and a clear path to a credit recommendation without a single high-stakes test day.

Frequently Asked Questions about SQL Joins

Final Thoughts on SQL Joins

SQL joins stop feeling abstract when you tie them to one tiny dataset and watch the row count change. That is the whole trick. You do not need 12 tables, and you do not need fancy database features. You need 1 customer table, 1 order table, and a clear idea of which rows each join keeps. INNER JOIN shows only matches. LEFT JOIN keeps every row from the left table. RIGHT JOIN keeps every row from the right table. FULL OUTER JOIN keeps everything and fills gaps with NULL. Those 4 moves cover most beginner questions, and they also expose the most common mistakes, like missing ON clauses, wrong keys, and bad assumptions about NULL. Try the same query with 3 rows, then 5 rows, then a table where one side has 0 matches. That small habit builds real comfort fast. If you can predict the result before you run it, you have already learned more than a lot of students do from a week of memorizing syntax. Start with one sample table pair today, and write your own join comparison before you move on to a bigger database.

How UPI Study credits actually work

Ready to Earn College Credit?

Credit recommended by ACE and NCCRS · Self-paced · Your college decides how credits transfer · $250/course or $99/month (US)

More on Technical Writing Course