I am trying to select data containing four percentage signs in a row. How can I escape the percentage signs so my LIKE condition works?
Thanks
I am trying to select data containing four percentage signs in a row. How can I escape the percentage signs so my LIKE condition works?
Thanks
Use
@%
with the escape character clause:This will search for all records that contain the
"%"
character in thefld
column.DB2/z has a slightly different format:
Obviously, you'll need to choose your escape character carefully so it won't interfere with the rest of your string but this is relatively easy for static strings. Dynamically built strings will require dynamically built queries so that it doesn't use a character from the string.