Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I need a select which would return results like this:

SELECT * FROM MyTable WHERE Column1 CONTAINS 'word1 word2 word3'

And I need all results, i.e. this includes strings with 'word2 word3 word1' or 'word1 word3 word2' or any other combination of the three.

All words need to be in the result.

1 Answer

0 votes
by (40.7k points)
  • To include any of the word use this query:

SELECT * FROM Table

WHERE column1 LIKE '%word1%'

OR column1 LIKE '%word2%'

OR column1 LIKE '%word3%'

  • If you want all the words to be present, then use this code:

SELECT * FROM Table

WHERE column1 LIKE '%word1%'

  AND column1 LIKE '%word2%'

  AND column1 LIKE '%word3%'

Related questions

0 votes
1 answer
asked Jul 20, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
asked Dec 17, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...