As you learned in the previous tutorial, you can also filter numerical records in the clause.
Today, we will teach you to filter string-text records.
Syntax
SQL has useful operators to filter records for case-sensitive and case-insensitive string comparison and wildcard pattern matching.
The following table shows the commonly used string-text operators.
Operator | Definition | Example in Query |
---|---|---|
= | Equals to; case-sensitive exact string comparison | |
!=, <> | Not equals to; case-sensitive exact string comparison | ; |
LIKE | Case-insensitive exact string comparison | |
NOT LIKE | Case-insensitive exact string comparison | |
IN (…) | String exists in a list | |
NOT IN (…) | String does not exist in a list | |
% | Represents zero, one, or multiple characters | Refer to Lesson 20 |
_ | Represents one characters | Refer to Lesson 20 |
Katie is a kindergarten teacher and wants to pull out the English scores for her students named Alice, Belle and Catherine.
Instead of writing the query with multiple operators,
You can simplify the query with the operator.
A journalist for the Olympics 2020 is writing an article on gold medalists in women's Rhythmic Gymnastics for the past 3 decades (2020 and 1990 inclusive) and requested the data from the Olympics data team.
Now it's your turn to use clause to filter string-text data!
Next Lesson
Dividing with Integer, Decimal and Float