OR condition in PostgreSQL

PostgreSQL OR To filter the results, the PostgreSQL OR condition is used with SELECT, INSERT, UPDATE and DELETE statements to satisfy either of the conditions.

Syntax:

WHERE condition_1
OR condition_2
OR condition_3
….
OR condition_n; 

Parameters: condition_1, condition_2… condition_n: They are used to specify the conditions to be strictly followed for selection.

Example: Students table:

ID NAME AGE
1 Joy 5
2 Smiley 13
3 Happy 11
4 Tom 15
5 Jerry 10
6 Bruno  6
7 David  8

Query:

SELECT *
FROM “STUDENTS”  
WHERE  “AGE” = 10  
OR  “AGE” = 15
ORDER BY “NAME”;

Output:

ID NAME AGE
5 Jerry 10
4 Tom 15
Please follow and like us:
Content Protection by DMCA.com