Joins

The Old Way: JOIN in the WHERE Clause

Senior Data Analyst
February 5, 2026
5 min read

The Legacy Code

I was reviewing an old query from 2005 and saw something strange:

SELECT *

FROM orders, customers

WHERE orders.customer_id = customers.id;

There was no `JOIN` keyword! What was this?

The Quest: The Implicit Join

Before the `JOIN ... ON` syntax became standard (ANSI-92), people wrote joins by listing tables with commas and putting the join condition in the `WHERE` clause. This is called an **Implicit Join** or **Comma Join**.

It works, but it's considered bad practice in modern SQL.

Why We Avoid It

1. **Readability**: It's hard to tell which `WHERE` conditions are for filtering and which are for joining.

2. **Error Risk**: If شما forget the join condition in the `WHERE` clause, you get a **Cartesian Product** (every row from Table A matched with every row from Table B—potentially millions of combinations).

The Modern Way

Always use explicit `JOIN ... ON` syntax:

-- Clear and safe

SELECT *

FROM orders

JOIN customers ON orders.customer_id = customers.id;

The "Oops" Moment

Someone once sent me a "comma join" query without the `WHERE` condition. It crashed the database.

**Pro Tip**: If شما see comma-separated tables in the `FROM` clause, treat it with caution. Ask: "Is the join condition definitely in the `WHERE`?"

The Victory

I rewrote the legacy query using modern syntax and added comments. The next analyst who reads it in 2030 will understand it immediately.

Your Task for Today

Find an old query using the comma-join style and rewrite it using explicit `JOIN ... ON` syntax.

*Day 37: Connecting Multiple Tables.*

Ready to put your knowledge into practice?

Join SQL Mastery and learn through interactive exercises.