Filtering String-Text Data

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.


Comparison and Logical Operators

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.

OperatorDefinitionExample in Query
=Equals to; case-sensitive exact string comparison
!=, <>Not equals to; case-sensitive exact string comparison;
LIKECase-insensitive exact string comparison
NOT LIKECase-insensitive exact string comparison
IN (…)String exists in a list
NOT IN (…)String does not exist in a list
%Represents zero, one, or multiple charactersRefer to Lesson 20
_Represents one charactersRefer to Lesson 20

Example 1: WHERE with / and

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.

Example 2: WHERE with and

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!

Practice Questions

Test Your Knowledge with DataLemur Questions

Next Lesson

Dividing with Integer, Decimal and Float