Natual Join is a type of join in SQL which combines row from 2 tables based on common column which has same name and datatype. It automatically matches the 2 columns and eliminates the duplicate column. read more
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Email VARCHAR(100),
City VARCHAR(50)
);
CustomerID | FirstName | LastName | City | |
---|---|---|---|---|
1 | John | Doe | john.doe@example.com | New York |
2 | Jane | Smith | jane.smith@example.com | Los Angeles |
3 | Emily | Johnson | emily.j@example.com | Chicago |
CREATE TABLE Orders (
OrderID INT PRIMARY KEY,
CustomerID INT,
OrderDate DATE,
TotalAmount DECIMAL(10, 2),
City VARCHAR(50),
FOREIGN KEY (CustomerID) REFERENCES Customers(CustomerID)
);
OrderID | CustomerID | OrderDate | TotalAmount | City |
---|---|---|---|---|
101 | 1 | 2024-01-10 | 250.50 | New York |
102 | 2 | 2024-01-11 | 150.00 | Los Angeles |
103 | 3 | 2024-01-12 | 300.75 | Chicago |
SELECT *
FROM TABLE1
NATURAL JOIN TABLE2;
SELECT *
FROM Orders
NATURAL JOIN Customers;
In this scenario, SQL combines the Orders
and Customers
tables using a natural join. The join is performed based on the common columns, CustomerID
and City
, which appear at the beginning of the resulting table.
As a result, SQL brings together columns like FirstName
, LastName
, and Email
from the Customers
table, along with OrderID
, OrderDate
, and TotalAmount
from the Orders
table. The shared columns, CustomerID
and City
, are seamlessly included in the result without duplication, making the output clear and concise.
I hope this explanation was helpful for you, consider sharing this with your friends. thank you.
Hi, I am Vishal Jaiswal, I have about a decade of experience of working in MNCs like Genpact, Savista, Ingenious. Currently i am working in EXL as a senior quality analyst. Using my writing skills i want to share the experience i have gained and help as many as i can.
Pivot tables are a powerful tool for summarizing and analyzing data, and Python’s Pandas library…
Welcome to Section 3 of our Data Science Interview Questions series! In this part, we…
Welcome back to our Data Science Interview Questions series! In the first section, we explored…
Data Science Questions in Section 1 focus on the essential concepts of Data Visualization and…
In this article, we’ve compiled 30 carefully selected multiple choice questions (MCQs) with answers to…
Welcome to Day 15 of our Python for Data Science journey!On Day 15, we dived…