Difference between revisions of "PostgreSQL-Database/C2/JOIN-and-INNER-JOIN-Clause/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(5 intermediate revisions by 2 users 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:''' Anjali Satdive / EduPyramids.
+
'''Author:''' EduPyramids.
  
'''Keywords:''' PostgreSQL, pgAdmin 4, 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 19: Line 21:
 
'''Learning Objectives'''
 
'''Learning Objectives'''
  
|| In this tutorial, we will learn about,
+
|| In this tutorial, we will learn,  
* '''JOIN Clause'''
+
* About '''JOIN''' and '''INNER JOIN clause''' and
* '''INNER JOIN Clause''' and
+
 
* How to combine data from two related tables.
 
* How to combine data from two related tables.
  
Line 28: Line 29:
 
'''System Requirements'''
 
'''System Requirements'''
  
'''Ubuntu 24.04''' LTS
+
* '''Ubuntu 24.04''' LTS
  
'''PostgreSQL version 18.1''', and
+
* '''PostgreSQL version 18.1''', and
  
'''PgAdmin 4 version 9.11'''.
+
* '''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 41: Line 42:
  
 
'''Pre-requisites'''
 
'''Pre-requisites'''
 +
 +
[https://edupyramids.org/ https://EduPyramids.org] '''
  
 
|| To follow this tutorial,
 
|| To follow this tutorial,
  
* Learners should have '''PostgreSQL''' and '''pgAdmin 4'''
+
* Learners should have '''PostgreSQL''' and '''pgAdmin4'''
 
* For the prerequisite '''PostgreSQL''' tutorials, please visit this website.
 
* For the prerequisite '''PostgreSQL''' tutorials, please visit this website.
  
Line 54: 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'''
+
* '''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 93: Line 96:
 
|| This is the syntax of the '''Joins clause.'''
 
|| This is the syntax of the '''Joins clause.'''
  
'''SELECT column_names,''' specifies which columns to display.
+
'''SELECT column_names''', specifies which columns to display.
  
 
'''FROM table1''' takes data from the first table.
 
'''FROM table1''' takes data from the first table.
Line 112: Line 115:
 
|-
 
|-
  
||  
+
|| Showing Student table.
 
+
 
|| Let us create another table named '''results'''.
 
|| Let us create another table named '''results'''.
  
Line 119: Line 121:
  
 
|-
 
|-
||  
+
|| Type:  
Type:  
+
  
 
'''CREATE TABLE results ('''
 
'''CREATE TABLE results ('''
Line 149: Line 150:
  
 
|| Now let us insert a few sample records into the '''results''' table.
 
|| Now let us insert a few sample records into the '''results''' table.
 +
 
Let us execute the query.
 
Let us execute the query.
  
 
|-
 
|-
||  
+
|| Point to the output.
 
|| The data is inserted successfully.
 
|| The data is inserted successfully.
  
Line 176: Line 178:
 
|-
 
|-
 
|| Highlight the output.
 
|| Highlight the output.
 +
 
Highlight matching lines.
 
Highlight matching lines.
 
|| Notice that we can see data from both the tables.
 
|| Notice that we can see data from both the tables.
 +
 
Only the matching records from the tables are displayed.
 
Only the matching records from the tables are displayed.
  
Line 189: Line 193:
 
By default, the '''JOIN''' clause performs an '''INNER JOIN'''.
 
By default, the '''JOIN''' clause performs an '''INNER JOIN'''.
  
'''INNER JOIN''' explicitly returns only the matching records from both the tables.
+
'''INNER JOIN''' explicitly returns only the matching records from both the tables.
  
 
|-
 
|-
Line 227: Line 231:
  
 
Observe the output.
 
Observe the output.
 
  
  
 
|-
 
|-
 
|| Highlight output
 
|| Highlight output
 
 
 
|| You will notice that the result is the same as in the previous '''JOIN''' query.
 
|| You will notice that the result is the same as in the previous '''JOIN''' query.
  
Line 254: Line 255:
 
'''Summary'''
 
'''Summary'''
  
In this tutorial, we have learnt about,
+
In this tutorial, we have learnt,  
 
+
• '''JOIN Clause'''.
+
 
+
• '''INNER JOIN Clause'''.
+
 
+
• How to combine data from two related tables.
+
  
 +
*  About '''JOIN''' and '''INNER JOIN clause''' and
 +
* How to combine data from two related tables.
 +
 
|| With this, we come to the end of this tutorial.
 
|| With this, we come to the end of this tutorial.
  
Line 273: Line 271:
 
'''As an Assignment,'''
 
'''As an Assignment,'''
  
Insert two new records into the table.
+
* Insert two new records into the table.
  
Execute the query using JOIN and INNER JOIN.
+
Execute the query using JOIN and INNER JOIN.
  
Observe the output.
+
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,
  • About JOIN and INNER JOIN clause and
  • How to combine data from two related tables.
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

https://EduPyramids.org

To follow this tutorial,
  • Learners should have PostgreSQL and pgAdmin4
  • For the prerequisite PostgreSQL tutorials, please visit this website.
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.

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.


This is because JOIN and INNER JOIN behave in the same way.

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 and INNER JOIN clause and
  • 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.

Contributors and Content Editors

ANJALISATDIVE, Madhurig