LIKE Pattern in SQL

Level 361 keystrokes

LIKE '%@gmail.com' finds email addresses that end with @gmail.com; % matches any sequence of characters.

SQL code

1SELECT
-- Returns the name and email columns
2 name,
3 email
4FROM
5 users
6WHERE
-- % matches any characters before @gmail.com
-- So this finds every email address ending in @gmail.com
7 email LIKE '%@gmail.com';

Output

+-------+------------------+
| name  | email            |
+-------+------------------+
| Alice | alice@gmail.com  |
| Bob   | bob@gmail.com    |
+-------+------------------+
2 rows in set
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this SQL code and how often they appear.

  • '× 2
  • ,× 1
  • ;× 1
  • .× 1
  • @× 1
  • %× 1

More SQL examples at level 3

← SQL typing practice