Menu
Coddy logo textTech

The OR keyword

Part of the Fundamentals section of Coddy's SQL journey — lesson 7 of 72.

The OR keyword means that we want one of the conditions to be true.

For example consider the following <b>people</b> table:

nameagegender
Joas13male
Holwa17male
Nohlas24female
Polar23male
Loopa18female
SELECT * 
FROM people
WHERE gender = 'female' OR age < 20

This query means that we are looking for all records that either the gender is female or the age is less than 20.

This will be the result:

nameagegender
Joas13male
Holwa17male
Nohlas24female
Loopa18female
challenge icon

Challenge

Easy

Available tables and columns:

  • <b>people</b>: <b>age</b>, <b>status</b>

Fetch all of the people who are either under age of 20 or above age 28 (not including 20 and not including 28).

Cheat sheet

The OR keyword returns records where at least one condition is true:

SELECT * 
FROM people
WHERE gender = 'female' OR age < 20

Returns rows where gender = 'female' or age < 20 (or both).

Try it yourself

SELECT * 
FROM people
-- Write your code below
WHERE
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals