Within the WHERE clause, the LIKE operator is used to pattern match the string form of a property's value. Its argument (likepattern) may contain the percent (“%”) and underscore (“_”) characters.

The likepattern must be enclosed in single quotes. Any literal single quote within the pattern must be escaped as two consecutive single quotes.

A likepattern with neither a percent (“%”) nor an underscore (“_”) character makes the LIKE operator equivalent to an equals (“=”) operator.

Within the likepattern, literal instances of percent (“%”) or underscore (“_”) must be escaped using the SQL ESCAPE clause which allows the definition of an arbitrary escape character within the context of a single LIKE statement. For example

SELECT * FROM mytype WHERE a LIKE 'foo\%' ESCAPE '\'

the above statement will select nodes of type 'mytype' with property 'a' that contain exactly the value 'foo%'

See also Pseudo-property jcr:path, Property Constraint, Path Constraint and jcr:like Function.