The WHERE condition clause allows us to define a condition and filter the data.
If there are more conditions, we can use the logical operator AND, which expresses „and at the same time“. This means that the query returns those records that meet all the conditions.
Structure:
SELECT column_name FROM table_name WHERE condition AND condition;
Example1:
We have a table Customer with this data:
CustomerID | Name | Hair | Salary |
---|---|---|---|
1 | Alechandro | brown | 100 |
2 | Katerina | blonde | 150 |
3 | Lucie | blonde | 30 |
4 | Thomas | black | 40 |
5 | Theodor | black | 120 |
6 | Thomassino | black | 99 |
7 | Knor | brown | 50 |
8 | Thor | blonde | 10 |
9 | Lucie | pink | 70 |
SELECT name FROM Customer WHERE hair = 'blonde' AND salary>10;
Thor and Lucie meet these conditions. Both have blond hair and a salary of more than 10. Arnold has blond hair, but his salary is less than 10.
NAME |
---|
Katerina |
Lucie |
I give people clear, functional, and proven instructions. I gently guide them so that they can fulfill their IT dreams.