×
×
SQL Tutorial
What is SQL SQL SELECT SQL SELECT DISTINCT SQL WHERE SQL INSERT SQL UPDATE SQL DELETE SQL AND, OR & NOT Clause SQL ORDER BY SQL LIKE Clause SQL IN Operator SQL BETWEEN Operator SQL MAX() and MIN() SQL COUNTSQL JOIN
SQL JOIN SQL INNER JOIN SQL LEFT JOIN SQL RIGHT JOIN SQL FULL OUTER JOINSQL INNER JOIN
The INNER JOIN keyword selects records that have matching values in both tables.
Syntax:
SELECT column_name(s)
FROM table1
INNER JOIN table2
ON table1.column_name = table2.column_name;
Customers table:
customer_id | fullname |
---|---|
1 | Kailash |
2 | Amit |
3 | Siddarth |
4 | Vikas |
Orders table:
order_id | amount | customer |
---|---|---|
1 | 2000 | 2 |
2 | 3000 | 4 |
3 | 1500 | 5 |
4 | 2500 | 7 |
Here, the SQL command selects customer_id and fullname columns (from the Customers table) and the amount column (from the Orders table).
QUERY:
SELECT Customers.customer_id, Customers.fullname, Orders.amount
FROM Customers
INNER JOIN Orders
ON Customers.customer_id = Orders.customer;
And, the result set will contain those rows where there is a match between customer_id (of the Customers table) and customer (of the Orders table).
Result:
customer_id | fullname | amount |
---|---|---|
2 | Amit | 2000 |
4 | Vikas | 3000 |
INNER JOIN With WHERE Clause
SELECT Customers.customer_id, Customers.fullname, Orders.amount
FROM Customers
INNER JOIN Orders
ON Customers.customer_id = Orders.customer
WHERE Orders.amount >= 3000;
Result:
customer_id | fullname | amount |
---|---|---|
4 | Vikas | 3000 |
SEARCH POST HERE
Support Us
Subscribe My YouTube Channel
Join Our Telegram Channel & Support Eachother
CATEGORIES
INTERVIEW QUESTIONS
POPULAR POSTS
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date
Copyright 2018 - 2024 Elevenstech Web Tutorials All rights reserved.