How do you write a SQL query to find a specific word in a SQL column. Example: I want to show all records that have the word Bob in it but do not want to include records that are Bobby or Bobble etc., only the exact word Bob. Hope that makes sense.
Software/Hardware used:
ASKED:
January 29, 2009 3:13 AM
UPDATED:
April 18, 2013 8:42 PM
I would suggest using a function to do the “hard” logic.
Use a simple query to find the records containing the substring of interest, then apply the function to those to get just the ones where the substring is a “word”.
The logic for the function is actually pretty simple:
The function finds EACH occurrence of the substring (might be more than one), then checks to make sure that the occurrence is not preceded or followed by an alpha character, which will handle any typical embedded text substrings.
Since some parts of an answer might change, what database product is being used?
Tom