Skip to main content

Command Palette

Search for a command to run...

NATURAL JOIN in SQL

Updated
1 min read
NATURAL JOIN in SQL
C

Senior Data Engineer • Contractor / Freelancer • GCP & AWS Certified

Another lesser known JOIN - the natural join. But maybe the NATURAL JOIN is not as obscure after all, since it has its own keyword, at least in a couple of SQL dialects - see PostgreSQL portrayed below (sorry, it's not supported in BigQuery, but it does recognize it).

So what's special about it? Well, it joins the tables based on columns that have the same name (and datatype) in the two tables. That is, we don't need to specify any join conditions.

Watch out because if there are no columns with the same name and datatype, it defaults to a Cartesian product is produced (which is what CROSS JOIN does).

Found it useful? Subscribe to my Analytics newsletter at notjustsql.com.


Enjoyed this? Here are some related articles you might find useful:

C

Thanks for reading!

C

It was very beneficial and how to deal the data regarding to requirements, by this article I came to know usage of a particular clause or function accordingly, thanks for providing these kind of articles.

1

Practical SQL

Part 29 of 50

Short, practical posts on SQL and BigQuery — from core language features to advanced query patterns. A reference for data practitioners at every level.

Up next

Short, almost non-technical guide to SQL query tuning as a Data Engineer

It's not all about those fancy details.

More from this blog

D

Datawise: A blog on SQL, BigQuery, Analytics, Python Tips and Tricks

204 posts

Data Engineer with a passion for transforming complex data landscapes into insightful stories. Here on my blog, I share insights, challenges, and the ever-evolving dance of technology and business.