Conditions with partial string matching


Filtering on partial strings is useful when the full string is not known or there may be spelling variations.


EXAMPLE DATABASE: World

DATA INPUT

Table organization in the database World.mdb is used as input.



QUERY like_beginwith

SELECT *
FROM organization
WHERE name LIKE "africa*";

Query like_beginwith produces the output below which contains 2 records where the organization name begins with africa. Note that the partial string match is not case sensitive.



QUERY like_endwith

SELECT *
FROM organization
WHERE name LIKE "*africa";

Query like_endwith produces the output below which contains 2 records where the organization name ends with africa. Note that the partial string match is not case sensitive.



QUERY like_embedded

SELECT *
FROM organization
WHERE name LIKE "*africa*";

Query like_embedded produces the output below which contains 14 records where the organization name contains africa. Note that the partial string match is not case sensitive.



DISCUSSION

The WHERE condition uses the like operator for the partial string matching. The * is used as a wildcard character that can match any characters. There are possibilities for more complex pattern matching. For more details, see the help page for like operator.


Last modified September 23, 2008 2:55 am