0% found this document useful (0 votes)
12 views

Database

The document discusses different types of joins in SQL including inner, left, right, and full joins. It provides the syntax for each type of join and examples of SQL code to implement each one along with sample output.

Uploaded by

Omkar Bhoyar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Database

The document discusses different types of joins in SQL including inner, left, right, and full joins. It provides the syntax for each type of join and examples of SQL code to implement each one along with sample output.

Uploaded by

Omkar Bhoyar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Join: A join clause is used to combine rows from two or more

tables, based on a related column between them.

Types of joins:

1. Inner join: SELECT


column_name(s) FROM
table1
INNER JOIN table2
ON table1.column_name = table2.column_name;

2. Left join: SELECT


column_name(s) FROM
table1
LEFT JOIN table2
ON table1.column_name = table2.column_name;

3. Right join: SELECT


column_name(s) FROM
table1
RIGHT JOIN table2
ON table1.column_name = table2.column_name;

4. Full join: SELECT


column_name(s) FROM
table1
FULL OUTER JOIN table2
ON table1.column_name = table2.column_name
WHERE condition;
SQL Code followed by Output Screenshot for each table
-- Operation 1: INNER JOIN

SQL Script:

1) INNER JOIN

SELECT User.u_add, User.u_email, Login.l_username, Login.l_password


FROM User
INNER JOIN Login
ON User.u_id=Login.l_id;

Output:
-- Operation 2: LEFT JOIN or LEFT OUTER JOIN

SQL Script:

2) LEFT JOIN
SELECT Login.l_username, Login.l_password,
Permission.p_module
FROM Login
LEFT JOIN Permission
ON Login.l_id=Permission.p_id;

Output:
-- Operation 3: RIGHT JOIN or RIGHT OUTER JOIN

SQL Script:
3) RIGHT JOIN
SELECT Login.l_username, Login.l_password,
Permission.p_module
FROM Login
RIGHT JOIN Permission
ON Login.l_id=Permission.p_id;

Output:
-- Operation 4: FULL JOIN or FULL OUTER JOIN

SQL Script:

4) FULL JOIN
SELECT Login.l_username, Login.l_password, Permission.p_module,
Permission.p_name
FROM Login
FULL JOIN Permission
ON Login.l_id=Permission.p_id;

Output:

You might also like