I was wondering how to generate a search SQL query for keywords:
I know:
SELECT * FROM table WHERE keyword LIKE %keyword%;
But how to work with multiple keywords.
I hope that makes sense...
I was wondering how to generate a search SQL query for keywords:
SELECT * FROM table WHERE keyword LIKE %keyword%;
But how to work with multiple keywords.
I hope that makes sense...
 
    
    SELECT * 
FROM `table`
WHERE keyword LIKE '%1%'
OR keyword LIKE '%2%'
OR keyword LIKE '%3%'
If I understand you right, this is what you're looking for
 
    
    Please check with below codes:
You can use FULL TEXT SEARCH
SELECT col1 FROM table_name
WHERE MATCH (col1, col2, col3)
AGAINST ('keywords');
For this, you need to apply fulltext index on columns in which you want to search.
You can use IN operator too like - 
SELECT col1 FROM table_name
WHERE col1 IN (keyword1, keyword2, keyword3, ...);
 
    
    You can use a combination of percent signs and underscore wildcards
SELECT * FROM table WHERE keyword LIKE "%keywordA_keywordB%";
Or use CONTAINS and do something like:
SELECT * FROM table 
    WHERE keyword CONTAINS "%keywordA%" AND keyword CONTAINS "%keywordB%";
