SQL Join on Multiple Columns 101: The Easy Way vs The Hard Way
By Laurent Maurer · October 26, 2022 · 4 min read
Difficulty Level: Expert
In this article, we will discuss how to use SQL Join on multiple columns.
This function is a built-in operation used for working on several tables.
Let’s dive into how to use it in both Code & No Code.
SQL Join on Multiple Columns: The Easy Way Without Coding
Let’s take a look at the following MongoDB Sample Datasets (Use our Public Sample Datasets for free).
- Step 1: Search and drag and drop the Join function in the sidebar:
- Step 2: Select in the dropdown list, the Join type you want to operate:
Step 3: Click on the “+” button as many times as required to join on multiple columns (in the example below, we have a pair of matching columns):
SQL Join on Multiple Columns: The Hard Way With Code
To reproduce the same output as above but with code, you need to write the following query:
SELECT account_id, account_id, transactions_symbol, products FROM accounts INNER JOIN transactions ON account_id.accounts =account_id.transactions AND transactions_symbol.transactions = products.accounts
The more you want to join on multiple columns the longer your SQL query will be. Your SQL query won’t be optimized this way and less and less readable for any data practitioner.
At RestApp, we’re building a Data Activation Platform for modern data teams with our large built-in library of connectors to databases, data warehouses and business apps.
We have designed our next-gen data modeling editor to be intuitive and easy to use.
Discover the next-gen end-to-end data pipeline platform with our built-in No Code SQL, Python and NoSQL functions. Data modeling has never been easier and safer thanks to the No Code revolution, so you can simply create your data pipelines with drag-and-drop functions and stop wasting your time by coding what can now be done in minutes!
Discover Data modeling without code with our 14-day free trial!
Subscribe to our newsletter
Build better data pipelines
With RestApp, be your team’s data hero by activating insights from raw data sources.