# SQL OR

**Starting here?** This lesson is part of a full-length tutorial in using SQL for Data Analysis. Check out the beginning.

## The SQL OR operator

`OR`

is a logical operator in SQL that allows you to select rows that satisfy either of two conditions. It works the same way as `AND`

, which selects the rows that satisfy both of two conditions. Try `OR`

out by running this query against data from the Billboard Music Charts:

```
SELECT *
FROM tutorial.billboard_top_100_year_end
WHERE year_rank = 5 OR artist = 'Gotye'
```

You’ll notice that each row will satisfy one of the two conditions. You can combine `AND`

with `OR`

using parenthesis. The following query will return rows that satisfy **both** of the following conditions:

```
SELECT *
FROM tutorial.billboard_top_100_year_end
WHERE year = 2013
AND ("group" ILIKE '%macklemore%' OR "group" ILIKE '%timberlake%')
```

You will notice that the conditional statement `year = 2013`

will be fulfilled for every row returned. In this case, `OR`

is treated like one separate conditional statement because it’s in parentheses, so it must be satisfied in addition to the first statement of `year = 2013`

. You can think of the rows selected as being either of the following:

- Rows where
`year = 2013`

is true and`"group" ILIKE '%macklemore%'`

is true - Rows where
`year = 2013`

is true and`"group" ILIKE '%timberlake%'`

is true - Rows where
`year = 2013`

is true and`"group" ILIKE '%macklemore%'`

is true and`"group" ILIKE '%timberlake%'`

is true