OR Operator

In PostgreSQL, a boolean value can have one of three values: true, false, and null.

Result

true

true

t

true

'true'

true

'y'

true

'yes'

true

'1'

true

false

false

f

false

'false'

false

'n'

false

'no'

false

'0'

false

Postgres OR Operator Query Results

SELECT true OR true AS result;

true

SELECT true OR false AS result;

t

SELECT true OR null AS result;

t

SELECT false OR false AS result;

f

SELECT false OR null AS result;

null

SELECT false OR false AS result;

f

SELECT null OR null AS result;

null

Using the OR operator in the WHERE clause

The following example uses the OR operator in the WHERE clause to find the films that have a rental rate is 0.99 or 2.99

SELECT
  title,
  rental_rate
FROM
  film
WHERE
  rental_rate = 0.99 OR
  rental_rate = 2.99;

Output:

title            | rental_rate
-----------------------------+-------------
 Academy Dinosaur            |        0.99
 Adaptation Holes            |        2.99
 Affair Prejudice            |        2.99
 African Egg                 |        2.99
...

Last updated