Wednesday , May 29 2024

PostgreSQL EXISTS Condition

In today’s article, I will explain the use of the PostgreSQL EXISTS condition, which allows us to perform operations with the subquery set to TRUE or FALSE.

We will operate with ogrenci_all and ogrenci_vf tables, let’s see these tables and start our example.

Student_all table with student names:

ogrenci_vf table where student vize and final grades are entered:

We have seen our two tables above, now let’s list the students whose vize and final grades have been entered.

As can be seen above, there are 9 students whose midterm and final grades have been entered, and one student’s grade has not been entered.

At the beginning of my article, I talked about returning TRUE and FALSE values.

The query result after the EXISTS statement is TRUE, that is, TRUE as there are 9 records matching the sogrenci_all table and ogrenci_vf table numbers.

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories