Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
SQL

SQL: Understand JOIN Types — INNER, LEFT, RIGHT, FULL

- 04.07.26 - ErcanOPAK

🔗 JOIN Types = Which Rows to Include

INNER, LEFT, RIGHT, FULL — which to use? Know the difference for correct results.

📝 JOIN Types

-- INNER JOIN (only matching rows)
SELECT u.name, o.total
FROM users u
INNER JOIN orders o ON u.id = o.user_id;
-- Users without orders are excluded

-- LEFT JOIN (all left + matching right)
SELECT u.name, o.total
FROM users u
LEFT JOIN orders o ON u.id = o.user_id;
-- All users, users without orders have NULL

-- RIGHT JOIN (all right + matching left)
SELECT u.name, o.total
FROM users u
RIGHT JOIN orders o ON u.id = o.user_id;
-- All orders, orders without users have NULL

-- FULL OUTER JOIN (all rows from both)
SELECT u.name, o.total
FROM users u
FULL OUTER JOIN orders o ON u.id = o.user_id;
-- All users and orders, NULL where no match

🎯 When to Use

✅ INNER JOIN:
- Only need rows that have matches
- Sales data (orders with customers)
- Products with categories

✅ LEFT JOIN:
- Need all left rows (even without matches)
- Users with their orders (show users without orders)
- Products with reviews (show products without reviews)

✅ RIGHT JOIN:
- Opposite of LEFT (rare, same as LEFT with tables swapped)
- Usually avoid, use LEFT instead

✅ FULL OUTER JOIN:
- Need all rows from both tables
- Merge two datasets
- Rarely used, heavy performance

💡 Key Takeaways

  • INNER: Only matching rows
  • LEFT: All left rows (NULL for missing right)
  • RIGHT: All right rows (NULL for missing left)
  • FULL: All rows from both (NULL where missing)
  • Use LEFT JOIN most often

“INNER JOIN vs LEFT JOIN confused me. Now I know: INNER only matches, LEFT includes all left. Essential for SQL.”

— SQL Developer

Related posts:

SQL Server: Fix a Stored Procedure That Runs Fast Alone but Slow When Called From the App

SQL Server: Fix a Stored Procedure That Runs Fast Alone but Slow When Called From the App

SQL: Use Full-Text Search for Fast Text Search

SQL: Use Full-Text Search for Fast Text Search

How to get the first and the last day of previous month in SQL Server

How to get the first and the last day of previous month in SQL Server

Views: 16
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

.NET Core: Use Entity Framework Migrations for Database Changes
C#: Use Method Overloading for Multiple Signatures

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,080 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 869 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 672 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 585 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 562 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com