WAS v8.5 > Develop applications > Develop Dynamic and EJB query > Develop applications that use EJB query > EJB query language > WHERE clauseLIKE predicate
The LIKE predicate searches a string value for a certain pattern.
The syntax for this predicate is:
string-expression [NOT] LIKE pattern [ ESCAPE escape-character ]
The pattern value is a string literal or parameter marker of type string in which the underscore ( _ ) stands for any single character and percent ( % ) stands for any sequence of characters ( including empty sequence ). Any other character stands for itself. The escape character can be used to search for character _ and %. The escape character can be specified as a string literal or an input parameter.
If the string-expression is null, then the result is unknown.
If both string-expression and pattern are empty, then the result is true.
Example: LIKE predicate
- "LIKE" is true
- "LIKE %" is true
- e.name LIKE 12%3 is true for "123" "12993" and false for "1234"
- e.name LIKE 's_me' is true for "some" and "same", false for "soome"
- e.name LIKE '/_foo' escape '/' is true for "_foo", false for "afoo"
- e.name LIKE '//_foo' escape '/' is true for "/afoo" and for "/bfoo"
- e.name LIKE '///_foo' escape '/' is true for "/_foo" but false for "/afoo"
Related concepts:
EJB query language
WHERE clause
Related
Use EJB query