In today’s article, we will explain what the PostgreSQL ALL command is and make examples of the ALL command.
The ALL command works for all the results from the subquery, that is, it shapes the result according to the parameters ” < “, ” > ” , ” = “, ” != ” that we use for the records from the subquery.
Let’s do a more detailed search through the sample application.
In our student table, let’s want users with the last name ERDEM to return the higher of the vize results, but without doing this, let’s look at the data in our table.
We see that there are 10 records in our student table above.
Let’s write the plpgsql command that meets the condition I want above from among these records.
SELECT * FROM ogrenci WHERE vize > ALL(SELECT vize FROM ogrenci WHERE soyadi='ERDEM' );
When we looked at the first version of our table, we saw that there were 11 records, there were 3 records with the surname ERDEM, but when we look at the result, we see that there are 5 records.
The reason for this is that it is based on the largest value among 3 records with the surname ERDEM, that is, it evaluates those with more than 40 vize, and as a result, 5 records are returned.