Reputation: 13123
I have a sentence column in my table. I wish to select all sentences which contain a given word.
Words contain only the following letters: a-z, áéíóú
The only other character is a single space, separating each word in the sentence. There are no spaces at the start or end of a sentence. So sentences look like this:
"i am here"
"no im here"
selecting sentences containing the word "i" should only match the first sentence above.
How should I select these rows from my table?
Upvotes: 1
Views: 646
Reputation: 446
Based upon the information you have provided there are three permutations you need to cover.
So your query would look something like this ...
SELECT * FROM YourTableName
WHERE SentenceCol LIKE 'YOUR-SEARCH-WORD %'
OR SentenceCol LIKE '% YOUR-SEARCH-WORD %'
OR SentenceCol LIKE '% YOUR-SEARCH-WORD'
Upvotes: 2