Skip to main content

Conditional statements part 1


Sometimes we would like to fetch records that meet a certain condition.

For example

  • fetch all of the records that have the family name "Aothly" 
  • fetch all of the records that the amount is bigger than 5
  • fetch all of the records with the country "Mexico"

To add condition we can use the WHERE keyword

sales

coin amount
AGK 13
GOL 21
KLA 15
AGK 18

To fetch all of the records with the coin "AGK" we will write:

SELECT * FROM sales WHERE coin = "AGK"

To fetch all of the records with amount smaller than 20 we will write:

SELECT * FROM sales WHERE amount < 20