Eda Eren

August 19, 2023
  • SQL

Implicit vs. explicit JOINs

Let's say we have a customers table that looks similar to this:

customer_idfirst_namelast_name
1JohnDoe
2JaneSmith

And an items_ordered table that's looking like this:

customer_idorder_dateitemprice
12020-01-01Apple1.99
22020-02-02Banana0.99

Usually, we can join them using the INNER JOIN (or just JOIN) clause:

SELECT customer_id, first_name, last_name, order_date, item, price
FROM customers
INNER JOIN items_ordered
ON customers.customer_id = items_ordered.customer_id;
SELECT customer_id, first_name, last_name, order_date, item, price
FROM customers
INNER JOIN items_ordered
ON customers.customer_id = items_ordered.customer_id;

But, there is also another way to do the same thing, which is the implicit JOIN:

SELECT
customers.customer_id,
customers.first_name,
customers.last_name,
items_ordered.order_date,
items_ordered.item,
items_ordered.price
FROM customers, items_ordered
WHERE customers.customer_id = items_ordered.customer_id;
SELECT
customers.customer_id,
customers.first_name,
customers.last_name,
items_ordered.order_date,
items_ordered.item,
items_ordered.price
FROM customers, items_ordered
WHERE customers.customer_id = items_ordered.customer_id;

Looks a bit more cluttered.

For clarity's sake, using an explicit JOIN syntax makes more sense, and from what I've read, it seems to be no significant performance difference between the two, and the ANSI 92 standard is said to be recommending using modern explicit joins.