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

簡単な方法の 1 つは、クエリ内の単語の前後にスペースを入れることです。

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

ただし、文章が「diamond.」で終わる場合はうまく機能しません。

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

于 2011-06-28T06:26:23.973 に答える