LIKE Examples

The query shown next retrieves data for those PART table records containing a PNAME column value that begins with "C":

SELECT pno, pname, weight
  FROM part
  WHERE pname LIKE "C%"

In the following example, the query match string "% of Total" is used to search the statistic column of a table called stats:

SELECT *
  FROM stats
  WHERE statistic LIKE "\% of Total"
    ESCAPE "\"

Note that in DB2 mode (for purposes of LIKE operator string comparison) trailing blanks are significant for data values located in fixed length CHAR data type columns. For example, if a character data type column with the a field length of ten contains a data value of "Sales ", a query containing the LIKE operator string "%s " would return a match. However, a LIKE operator string of "%s" in the same query would not return a match.