8.5.4.4 LIKE

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 8.5.2.2 Pseudo-property jcr:path, 6.6.3.3 Property Constraint, 6.6.3.4 Path Constraint and 6.6.5.1 jcr:like Function.