2011-06-28 13 views
0

私のデータベーステーブルには、テキストフィールドであるフィールド "description"があります。それはそれのような値が含まれています:テキストフィールド(1つ以上の文字列)を持つ列の文字列の完全一致の照会

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' しかし、それはどんな結果

を与えていません

質問する方法を教えてください。

おかげ ロミ

答えて

0

1つの簡単な方法は、クエリ内の単語の前後にスペースを入れることです:「ダイヤモンド」あなたの文章がで終わる場合

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

がうまく動作しない、しかし、 。

もっと複雑なことには、フルテキストインデックス作成を使用する必要があります。これはMySQLでの経験がありません。

0
SELECT .... WHERE ' ' + REPLACE(description,'.','') + ' ' LIKE '% diamond %' 

これは、文章が「ダイヤモンド」で始まり、/または終わる場合に機能します。

関連する問題