Difference between revisions of "PostgreSQL-Database/C2/JOIN-and-INNER-JOIN-Clause/English"
| Line 3: | Line 3: | ||
'''Author:''' Anjali Satdive / EduPyramids. | '''Author:''' Anjali Satdive / EduPyramids. | ||
| − | '''Keywords:''' PostgreSQL, | + | '''Keywords:''' PostgreSQL, pgAdmin4, Join clause, INNER JOIN clause, syntax, students, results, EduPyramids, video tutorial. |
| Line 32: | Line 32: | ||
• '''PostgreSQL version 18.1''', and | • '''PostgreSQL version 18.1''', and | ||
| − | • ''' | + | • '''PgAdmin4 version 9.11'''. |
|| To record this tutorial, I am using the following setup. | || To record this tutorial, I am using the following setup. | ||
| Line 44: | Line 44: | ||
|| To follow this tutorial, | || To follow this tutorial, | ||
| − | * Learners should have '''PostgreSQL''' and ''' | + | * Learners should have '''PostgreSQL''' and '''pgAdmin4''' |
* For the prerequisite '''PostgreSQL''' tutorials, please visit this website. | * For the prerequisite '''PostgreSQL''' tutorials, please visit this website. | ||
Revision as of 10:57, 8 May 2026
Title of the Script: JOIN and INNER JOIN Clause
Author: Anjali Satdive / EduPyramids.
Keywords: PostgreSQL, pgAdmin4, Join clause, INNER JOIN clause, syntax, students, results, EduPyramids, video tutorial.
| Visual Cue | Narration |
|---|---|
| Title Slide | Welcome to this Spoken Tutorial on JOIN and INNER JOIN Clause. |
| Slide 2
Learning Objectives |
In this tutorial, we will learn about,
|
| Slide 3
System Requirements • Ubuntu 24.04 LTS • PostgreSQL version 18.1, and • PgAdmin4 version 9.11. |
To record this tutorial, I am using the following setup. |
|
Slide 4 Pre-requisites |
To follow this tutorial,
|
| Slide 5
Code Files The following code file is required to practice this tutorial. • Jc-commands.txt This file is provided in the Code Files link on this tutorial page. Please download and extract the file. |
The following code file is required to practice this tutorial.
This file is provided in the Code Files link of this tutorial page. Please download and extract the file. |
| Let us get started. | |
| Slide 6
JOIN Clause |
The JOIN Clause combines rows from different tables using a related column. |
| Slide 7
Syntax of JOIN Clause SELECT column_name(s) FROM table1 JOIN table2 ON table1.common_column = table2.common_column; |
This is the syntax of the Joins clause.
SELECT column_names, specifies which columns to display. FROM table1 takes data from the first table. JOIN table 2 combines table 2 with table1. ON clause matches values in common columns of both the tables. |
| Highlight student table | So far, we have worked with a single table named students.
However, in real-world databases, data is usually stored in multiple related tables. To retrieve related data from multiple tables, we use the JOIN clause. |
| Let us create another table named results.
This table will store studentid and marks. | |
|
Type: CREATE TABLE results ( studentid VARCHAR(10), marks INT ); Click the Execute query button. |
Let us type this query.
This creates a table named results. The studentid column will be common in both the tables. Let us execute the query to see the output. |
| Type:
INSERT INTO results VALUES ('S101', 85), ('S102', 90), ('S103', 78); Click the Execute query button. |
Now let us insert a few sample records into the results table.
Let us execute the query. |
| The data is inserted successfully. | |
| Type:
SELECT students.studentid, studentname, marks FROM students JOIN results ON students.studentid = results.studentid; Click the Execute query button. |
Now let us type this query.
This query combines the students and results tables using the studentid column. Let me execute the query. |
| Highlight the output.
Highlight matching lines. |
Notice that we can see data from both the tables.
Only the matching records from the tables are displayed. |
| Slide 10
INNER JOIN |
Let us learn about Inner Join.
By default, the JOIN clause performs an INNER JOIN. INNER JOIN explicitly returns only the matching records from both the tables. |
| Slide 11
Syntax of INNER JOIN SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.common_column = table2.common_column; |
Here is the syntax of the Inner Join. |
| Type:
SELECT students.studentid, studentname, marks FROM students INNER JOIN results ON students.studentid = results.studentid; Click the Execute query button.
|
Now let us type this query.
This query joins the students table and results table with matching columns. Click on the Execute Query button. Observe the output.
|
| Highlight output
|
You will notice that the result is the same as in the previous JOIN query.
|
| Highlight JOIN
Highlight INNER JOIN |
If we write JOIN, it automatically performs an INNER JOIN.
However, using INNER JOIN makes the query clearer and easier to read.
|
| Slide 10
Summary In this tutorial, we have learnt about, • JOIN Clause. • INNER JOIN Clause. • How to combine data from two related tables. |
With this, we come to the end of this tutorial.
Let us summarise. |
| Slide 11
Assignment As an Assignment, • Insert two new records into the table. • Execute the query using JOIN and INNER JOIN. • Observe the output. |
We encourage you to try this assignment.
|
| Slide 12
Thank you This Spoken Tutorial is brought to you by EduPyramids Educational Private Limited SINE IIT Bombay. |
Thank You. |