0% found this document useful (0 votes)
15 views1 page

SQL Joins SQL Joins Are Used To Com

SQL Joins are used to combine rows from multiple tables based on related columns, allowing data retrieval in a single query. There are four main types of joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN, each serving different purposes in how they handle matching and non-matching records. The choice of join type depends on the specific requirements of the query.

Uploaded by

rock singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

SQL Joins SQL Joins Are Used To Com

SQL Joins are used to combine rows from multiple tables based on related columns, allowing data retrieval in a single query. There are four main types of joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN, each serving different purposes in how they handle matching and non-matching records. The choice of join type depends on the specific requirements of the query.

Uploaded by

rock singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

SQL Joins: SQL Joins are used to combine rows from two or more tables based on a

related column between them. They allow you to retrieve data from multiple tables
in a single query

Example of INNER JOIN

The INNER JOIN keyword selects records that have matching values in both tables.

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate


FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
This query retrieves orders along with the customer names for those orders

Types of SQL Joins

1. INNER JOIN

Returns records that have matching values in both tables.

2. LEFT (OUTER) JOIN

Returns all records from the left table, and the matched records from the right
table. If no match is found, NULL values are returned for columns from the right
table.

SELECT Student.NAME, StudentCourse.COURSE_ID


FROM Student
LEFT JOIN StudentCourse ON StudentCourse.ROLL_NO = Student.ROLL_NO;

3. RIGHT (OUTER) JOIN

Returns all records from the right table, and the matched records from the left
table. If no match is found, NULL values are returned for columns from the left
table.

SELECT Student.NAME, StudentCourse.COURSE_ID


FROM Student
RIGHT JOIN StudentCourse ON StudentCourse.ROLL_NO = Student.ROLL_NO;

4. FULL (OUTER) JOIN

Returns all records when there is a match in either left or right table. If no
match is found, NULL values are returned for columns from either table.

SELECT Student.NAME, StudentCourse.COURSE_ID


FROM Student
FULL JOIN StudentCourse ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Note: The choice of join type depends on the specific requirements of your query

You might also like