0

在我的数据库表中,我有一个“描述”字段,它是一个文本字段。它包含类似的值:

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.

我想查询包含确切单词“钻石”的列

当我查询时,select description from tproduct where description like '%diamond%' 它给了我结果,但它作为通配符查询运行

我想在哪里精确匹配“钻石”

我做了选择description from tproduct where description ='diamond' 但它没有给出任何结果

请告诉我如何查询这个。

谢谢罗米

4

2 回答 2

0

一种简单的方法是在查询中的单词周围放置空格:

SELECT ... WHERE description LIKE '% diamond %';

但是,如果您的句子以“钻石”结尾,那效果就不太好了。

对于更复杂的事情,你真的需要使用某种全文索引,我在 MySQL 中没有经验。

于 2011-06-28T06:26:23.973 回答
0
SELECT .... WHERE ' ' + REPLACE(description,'.','') + ' ' LIKE '% diamond %'

如果您的句子以“钻石”开头和/或结尾,这将起作用。

于 2015-07-07T14:07:59.393 回答