Database Engineering
  • Need of Database
  • Database and Database Management System
  • What is Relational Database Model ?
  • Installing Postgresql
    • Installing PostgreSQL on Linux
    • Installing PostgreSQL on Windows
    • Installing PostgreSQL on Mac
    • Postgres in Docker
  • What happens during the initial installation ?
    • Roles, Users & Groups
    • More examples on Roles
  • Sample Databases
    • DVD Rental Database
  • Querying Data
    • SELECT Query
    • Column Aliases
    • Order By
    • SELECT DISTINCT
    • DB-TASK-001
  • Filtering Data
    • WHERE ?
    • AND Operator
    • OR Operator
    • LIMIT
    • FETCH
    • IN
    • BETWEEN
    • LIKE
    • SIMILAR TO
    • IS NULL
    • ESCAPE
    • DB-TASK-002
  • Entity Relationship Diagram
    • What is an ER Diagram ?
    • Entity
    • Identifiers
    • Relationship
    • Attributes
    • Cardinality
    • Entity Relationship Diagram Tutorial
    • DB-TASK-003
  • Joins
    • Joins
    • Joins With Employee and Departments
  • Joins on E-Commerce
Powered by GitBook
On this page
  • Postgres OR Operator Query Results
  • Using the OR operator in the WHERE clause
  1. Filtering Data

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
...

PreviousAND OperatorNextLIMIT

Last updated 5 months ago