In my data base table i have a field "description" which is a text field. it contains values like it :
This bracelet is composed of round diamond surrounded by milgrain detailing. Its secure setting prevents it from twisting and ensures it will sit impeccably on her wrist.
This stylish design is the perfect accessory for the day or evening. Akoya cultured pearls are lined up by a string of bezel-set round diamond.
I want to query for the columns which contains exact word "diamond"
when i query as select description from tproduct where description like '%diamond%'
it give me the result but it runs as wil开发者_StackOverflow社区d card query
where i want to exact match for "diamond"
I did as select description from tproduct where description ='diamond'
But it is not giving any result
Please tell me how to query for this.
Thanks Romi
One simple way is to put spaces around the word in your query:
SELECT ... WHERE description LIKE '% diamond %';
That doesn't work so well if your sentence ends with "diamond.", however.
For something much more complex, you really need to use some sort of full-text indexing, which I have no experience with in MySQL.
SELECT .... WHERE ' ' + REPLACE(description,'.','') + ' ' LIKE '% diamond %'
This will work if your sentence starts and/or ends with 'diamond.'
精彩评论