Conditional statements part 3
Conditions are booleans. Boolean is a data type with two possible values: TRUE
or FALSE
.
For example
10 > 100
- FALSE10 > 5
- TRUE10 > 5 AND 100 < 5
- FALSE
Boolean columns have only two values - either 1 or 0. TRUE
indicates 1 and FALSE
indicates 0
We can replace columns such as employed or unemployed to 1
or 0
to make it easier to filter data. To filter data using booleans we will use the IS TRUE
or IS NOT TRUE
keywords.
SELECT *
FROM table1
WHERE col1 IS NOT FALSE AND col2 IS TRUE
No Comments