We, at the company,  had to find all cities in my city table which name were composed of more than one word and the last word should have only two characters, like “Berlin SO”, “Santa Fe”…

Phillip Gagnon, our I.T. manager, showed us two simple ways to list them using wildcards:
{code type=sql}
SELECT cityID, cityName
FROM cities
WHERE right(cityName, 3) like ‘ __'{/code}

and another way:
{code type=sql}
SELECT cityID, cityName
FROM cities
WHERE right(cityName, 3) like ‘ %%'{/code}

One thought on “SQL: Tips for Where Clause With Wildcards

Leave a Reply