I have a table with a column "Sentence"
Sentence
---------------------------
I eat chocolate today
I go to Hospital I am Hurt
I went to sleep Bye
I am very Hungry
I am done
You are beautiful
I am using the query
SELECT * from table WHERE Sentence LIKE '%am%'
This will return
I go to Hospital I am Hurt
I am very Hungry
I am done
But I want the LIKE Statement to return
I am very Hungry
I am done
only.
So Is there any way so I can make LIKE statement to check for the first 8 characters or something like that? Help me to do that.
You can use substr()
to get the first eight characters and apply the LIKE
operation on them.
SELECT *
FROM elbat
WHERE substr(sentence, 1, 8) LIKE '%am%';