且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL SELECT WHERE 字段包含单词

更新时间:2023-11-26 18:51:28

相当慢,但包含任何词的工作方法:

Rather slow, but working method to include any of words:

SELECT * FROM mytable
WHERE column1 LIKE '%word1%'
   OR column1 LIKE '%word2%'
   OR column1 LIKE '%word3%'

如果您需要所有词出现,请使用:

If you need all words to be present, use this:

SELECT * FROM mytable
WHERE column1 LIKE '%word1%'
  AND column1 LIKE '%word2%'
  AND column1 LIKE '%word3%'

如果你想要更快的速度,你需要查看全文搜索,这对于每种数据库类型都是非常具体的.

If you want something faster, you need to look into full text search, and this is very specific for each database type.