Difference between revisions of "PostgreSQL-Database/C2/JOIN-and-INNER-JOIN-Clause/English"
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
'''Title of the Script:''' JOIN and INNER JOIN Clause | '''Title of the Script:''' JOIN and INNER JOIN Clause | ||
| − | '''Author:''' | + | '''Author:''' EduPyramids. |
'''Keywords:''' PostgreSQL, pgAdmin4, Join clause, INNER JOIN clause, syntax, students, results, EduPyramids, video tutorial. | '''Keywords:''' PostgreSQL, pgAdmin4, Join clause, INNER JOIN clause, syntax, students, results, EduPyramids, video tutorial. | ||
| Line 12: | Line 12: | ||
|- | |- | ||
| − | || '''Title Slide''' | + | || '''Slide 1''' |
| + | |||
| + | '''Title Slide ''' | ||
|| Welcome to this Spoken Tutorial on '''JOIN''' and '''INNER JOIN Clause'''. | || Welcome to this Spoken Tutorial on '''JOIN''' and '''INNER JOIN Clause'''. | ||
| Line 20: | Line 22: | ||
|| In this tutorial, we will learn, | || In this tutorial, we will learn, | ||
| − | * About '''JOIN | + | * About '''JOIN''' and '''INNER JOIN clause''' and |
* How to combine data from two related tables. | * How to combine data from two related tables. | ||
| Line 55: | Line 57: | ||
The following '''code file''' is required to practice this tutorial. | 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. | This file is provided in the '''Code Files''' link on this tutorial page. | ||
| Line 255: | Line 257: | ||
In this tutorial, we have learnt, | In this tutorial, we have learnt, | ||
| − | * About '''JOIN | + | * About '''JOIN''' and '''INNER JOIN clause''' and |
* How to combine data from two related tables. | * How to combine data from two related tables. | ||
| Line 269: | Line 271: | ||
'''As an 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. | || We encourage you to try this assignment. | ||
Latest revision as of 16:21, 8 May 2026
Title of the Script: JOIN and INNER JOIN Clause
Author: EduPyramids.
Keywords: PostgreSQL, pgAdmin4, Join clause, INNER JOIN clause, syntax, students, results, EduPyramids, video tutorial.
| Visual Cue | Narration |
|---|---|
| Slide 1
Title Slide |
Welcome to this Spoken Tutorial on JOIN and INNER JOIN Clause. |
| Slide 2
Learning Objectives |
In this tutorial, we will learn,
|
| Slide 3
System Requirements
|
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.
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. |
| Showing Student table. | 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. |
| Point to the output. | 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,
|
With this, we come to the end of this tutorial.
Let us summarise. |
| Slide 11
Assignment As an Assignment,
|
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. |