# Conditional statements part 2

Creating a query with only one condition is not sufficient. Sometimes we would like to check something more complicated. For that SQL (and many other programming languages) have the `AND`, `OR`, and `NOT` keywords to increase our ability to fetch the right result we need.

The `AND` and `OR` keywords are used like this:

```sql
SELECT col1, col2 
FROM table1
WHERE condition1 AND condition2 OR condition3 ...

```

<div class="Lesson_content__j6FUx" id="bkmrk--1"><div code=""><div copy="">  
</div></div></div>We can stack as many conditions as we want together.

<div class="Lesson_content__j6FUx" id="bkmrk--2">---

</div>**people**

<div class="Lesson_content__j6FUx" id="bkmrk-name-age-gender-joas"><figure class="table"><table><thead><tr><th>name</th><th>age</th><th>gender</th></tr></thead><tbody><tr><td>Joas</td><td>13</td><td>male</td></tr><tr><td>Holwa</td><td>17</td><td>male</td></tr><tr><td>Nohlas</td><td>24</td><td>female</td></tr><tr><td>Polar</td><td>23</td><td>male</td></tr><tr><td>Loopa</td><td>18</td><td>female</td></tr></tbody></table>

</figure></div>The `AND` keyword means that **both** conditions must be true; if either of them is not, then the condition will not be met.

For example, if we will write

```sql
SELECT * 
FROM people
WHERE gender = "female" AND age < 20

```

<div class="Lesson_content__j6FUx" id="bkmrk--3"><div code=""><div copy="">  
</div></div></div>It means that we are looking for all records that the gender is "female" and the age is less than 20.

This will be the result:

<div class="Lesson_content__j6FUx" id="bkmrk-name-age-gender-loop"><figure class="table"><table><thead><tr><th>name</th><th>age</th><th>gender</th></tr></thead><tbody><tr><td>Loopa</td><td>18</td><td>female</td></tr></tbody></table>

</figure></div>The `OR` keyword means that we want one of the conditions will be true.

For example, if we take the same example from above and change the `AND` keyword to `OR`

```sql
SELECT * 
FROM people
WHERE gender = "female" OR age < 20

```

<div class="Lesson_content__j6FUx" id="bkmrk--4"><div code=""><div copy="">  
</div></div></div>It 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:

<div class="Lesson_content__j6FUx" id="bkmrk-name-age-gender-joas-1"><figure class="table"><table><thead><tr><th>name</th><th>age</th><th>gender</th></tr></thead><tbody><tr><td>Joas</td><td>13</td><td>male</td></tr><tr><td>Holwa</td><td>17</td><td>male</td></tr><tr><td>Nohlas</td><td>24</td><td>female</td></tr><tr><td>Loopa</td><td>18</td><td>female</td></tr></tbody></table>

</figure></div>The `NOT` keywords mean that we don't want the condition to be met.

For example, if we write:

```sql
SELECT * 
FROM people
WHERE NOT gender = "male"

```

<div class="Lesson_content__j6FUx" id="bkmrk--5"><div code=""><div copy="">  
</div></div></div>This will be the result:

<div class="Lesson_content__j6FUx" id="bkmrk-name-age-gender-nohl"><figure class="table"><table><thead><tr><th>name</th><th>age</th><th>gender</th></tr></thead><tbody><tr><td>Nohlas</td><td>24</td><td>female</td></tr><tr><td>Loopa</td><td>18</td><td>female</td></tr></tbody></table>

</figure></div><div class="Lesson_challengeContainer___d1_L" id="bkmrk--6"></div><div class="Lesson_challengeContainer___d1_L" id="bkmrk-easy"><div class="Lesson_challengeTop___c7ZK"></div></div>