PostgreSQL-Database/C2/Logical-Operators/English

From Script | Spoken-Tutorial
Revision as of 16:10, 17 April 2026 by Ketkinaina (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Title of the Script: Logical Operators in PostgreSQL

Author: EduPyramids / Ketki Bhamble

Keywords: PostgreSQL, pgAdmin 4, Logical operators, AND, OR, NOT, WHERE, EduPyramids, Video Tutorial.

Visual Cue Narration
Slide 1

Title Slide

Welcome to this Spoken Tutorial on Logical Operators in PostgreSQL.
Slide 2

Learning Objectives

In this tutorial, we will learn about
  • AND, OR and NOT operators.
Slide 3

System Requirements

  • Ubuntu 24.04 LTS
  • PostgreSQL version 18.1, and
  • PgAdmin 4 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 pgAdmin 4
  • For the prerequisite PostgreSQL tutorials, please visit this website.
Slide 5

Code Files

The following code file is required to practice this tutorial:

  • lo-commands.txt

This file is provided in the Code Files link on this tutorial page.

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

Logical Operators

Logical operators are used to combine multiple conditions in a query.

They help to filter records by evaluating conditions.

We will use AND, OR, and NOT operators to explain various conditions.

Let us use the AND operator in a query.

I have opened the pgAdmin 4 interface and connected to the localhost server.

Type:

SELECT *

FROM students

WHERE city = 'Pune' AND gender = 'Female';

Highlight:WHERE

Highlight:AND

Let us type the following query.

Here, we are using the WHERE clause along with the AND operator.

The condition checks if the city is Pune and gender is Female.

In AND operation, only those records are shown that satisfy both the conditions.

click the execute query button.

Point

Click the Execute query icon on the toolbar.

The output shows only two records that satisfy the given condition.

Observe that records of only female students from Pune are displayed.

Let us use the OR operator in an example.
Type:


SELECT *

FROM students

WHERE city = 'Mumbai' OR city = 'Delhi';

Highlight:WHERE

Highlight:OR

Press the execute query button.

Now type the following query.

Here, we use the WHERE clause with the OR operator.

This condition checks whether the city is Mumbai or Delhi.

Rows that satisfy at least one of these conditions are displayed.

Let us execute the query.

We see the details of students from Mumbai and Delhi.

Now, let us see an example of the NOT operator.
Type:

SELECT *

FROM students

WHERE NOT gender = 'Male';

Highlight:WHERE

Highlight:NOT

Press the execute query button.

Type the following query.

Here, we use the WHERE clause with the NOT operator.

This condition excludes all the rows where gender is Male.

Let us execute the query.

The output shows the details of all the female students.

Slide 10

Summary

In this tutorial, we learnt about

  • AND, OR and NOT operators.
With this, we come to the end of this tutorial.

Let us summarise.

Slide 11

Assignment

As an Assignment,

  • Retrieve the details of students who are from Chennai and whose gender is Female.
  • Display the records of students who are from Hyderabad or Bangalore.
  • List all students who are not from Pune.
  • Find students whose gender is Male and not from Mumbai.
  • List student details where city is Jaipur or Ahmedabad, but gender is not Female.
We encourage you to do this assignment.
Slide 12

This Spoken Tutorial is brought to you by EduPyramids Educational Private Limited SINE IIT Bombay.

Thank you

Thank you for joining.

Contributors and Content Editors

Ketkinaina