2017-09-29 45 views
1

以下是該方案。SQL - 通配符搜索與AND

我們有一個名爲「描述」字段,要求是:

  1. 用戶可以給最多5個字進行搜索的結果。 例如:ab和cd和ef和gh和ij
  2. 它會給出具有所有上述5個單詞的描述。

任何人都可以請告訴我怎麼做到這一點。

任何指導將不勝感激。

感謝和問候, 阿爾蒂

+0

[全文搜索](https://docs.microsoft.com/en-us/sql/relational-databases/search/full-text-search)也許。 –

+0

你在這張桌子上有全文索引嗎? – Kyle

回答

1
select description from tablename where 
description like '%word1%' and 
description like '%word2%' and 
description like '%word3%' and 
description like '%word4%' and 
description like '%word5%' 

,如果他們是小於5它們是否爲null,將知道會發生什麼「的話」有用嗎?他們是「?空例如:

....(description like '%word2%' or word2 is null) and...