Question:
You need a SQL query that retrieves records where a specified column contains more than one specific word, regardless of word order.
Solution:
There are two ways to achieve this:
1. Contains any word
To include records containing any specified word, use the following query structure:
<code class="language-sql">SELECT * FROM [表名] WHERE [列名] LIKE '%[单词1]%' OR [列名] LIKE '%[单词2]%' ... OR [列名] LIKE '%[单词N]%'</code>
2. Contains all words
To include records containing all specified words, use the following structure:
<code class="language-sql">SELECT * FROM [表名] WHERE [列名] LIKE '%[单词1]%' AND [列名] LIKE '%[单词2]%' ... AND [列名] LIKE '%[单词N]%'</code>
Note: To improve performance, consider using database type-specific full-text search capabilities.
The above is the detailed content of How to Select SQL Records Containing Multiple Specific Words?. For more information, please follow other related articles on the PHP Chinese website!