Greater than and less than comparisons are possible, as shown
in table , and there are even more complex comparisons available.
Users often need to compare character strings to see if they match a certain
pattern. For example, sometimes you only want fields that begin with a certain
letter, or contain a certain word. The LIKE keyword allows such comparisons.
The query in figure returns rows where the firstname
begins with D.
The test firstname LIKE '%D%' returns rows where firstname contains a D anywhere in the firstname field, not just at the beginning. The effect of the having a % before and after a character allows the character to appear anywhere in the string.
More complex tests can be performed with LIKE, as shown in figure .
Attempting to find all character fields that end with a certain character can be difficult. For certain column types, it is quite easy. Just doing colname LIKE '%g' is enough to find all rows that end with g. For char() columns, like firstname, there are trailing spaces that make such comparisons difficult with LIKE. See section for complete coverage on character data types.