PostgreSQL-Database/C2/Logical-Operators/English
Title of the Script: Logical Operators in PostgreSQL
Author: EduPyramids
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
|
| 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. |
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:
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
|
With this, we come to the end of this tutorial.
Let us summarise. |
| Slide 11
Assignment As an Assignment,
|
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. |