Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2004

    Unanswered: String Comparision

    Lets say we have a table Column with value "This forumn is intended for anyone who wants to use the Structured Query Language (SQL) to access a database".
    If I say
    table.column like '%cc%' even it is embedded with in the word access it results true.
    How should I rephrase LIKE phrase so that it will return false if input parameter is "cc" and true if input parameter is "access"(yes it's something like word matching).
    If we can't get the result with LIKE then do we have any function in DB2 as I want to avoid OR/AND.

    Thanks in advance

  2. #2
    Join Date
    Nov 2004
    Provided Answers: 4
    What you want to do is to look for the token (word) "cc" and not for the substring "cc" in a string.

    That means that you should use table.column like '% cc %' (with spaces before and after cc). But if cc could start or end the string preceded or ended with 'nothing' (i.e. the first word of a string or the last word), ',', or '.' or ... things get really complicated. In that case the best way to handle this is by using regular expressions.

    You can read more about this at using regular expressions in SQL


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts