SQL LIKE
The LIKE command allows you to do string matching (with wildcards).
%matches any number of characters.- For example,
LIKE '%e'will match any string ending in "e" _matches one character.- For example,
LIKE 'ca_'will match "cat" but will not match "catch"
-- Works in PostgreSQL, MySQL, SQL Server, and Oracle
SELECT
*
FROM
buildings
WHERE
address LIKE '%Main St';
buildings table
| id | address |
|---|---|
| 1 | 123 Main St |
| 2 | 2 Maple St |
| 3 | 98 Main St |
| 4 | 5 Maple St |
Query results
| id | address |
|---|---|
| 1 | 123 Main St |
| 3 | 98 Main St |