SQL SELECT WHERE field contains words

0 votes

I require a SELECT command which will return the following to me:

SELECT * FROM Table WHERE Column1 CONTAINS 'w1 w2 w3'

And I need all of the results, so strings containing 'w2 w3 w1' or 'w1 w3 w2' or any other combination of the three are OK.

All words must appear in the final product.

Feb 21, 2022 in Database by Vaani
• 7,070 points
21,138 views

1 answer to this question.

0 votes

Use this query to include any of words:

SELECT * FROM mytable
WHERE Column1 LIKE '%w1%'
   OR Column1 LIKE '%w2%'
   OR Column1 LIKE '%w3%'

If you require all words, use this:

SELECT * FROM Table
WHERE Column1 LIKE '%w1%'
  AND Column1 LIKE '%w2%'
  AND Column1 LIKE '%w3%'

Get a further understanding from the SQL Certification Course

answered Feb 21, 2022 by Neha
• 9,020 points

Related Questions In Database

0 votes
1 answer

IN vs OR in the SQL WHERE Clause

I assume you want to know the ...READ MORE

answered Sep 24, 2018 in Database by DataKing99
• 8,250 points
4,826 views
0 votes
2 answers

How to select the nth row in a SQL database table?

SELECT * FROM ( SELECT ID, NAME, ROW_NUMBER() ...READ MORE

answered Apr 23, 2020 in Database by anand
• 140 points
27,871 views
0 votes
1 answer

SQL Switch/Case in 'where' clause

Without a case statement: SELECT column1, ...READ MORE

answered Feb 7, 2022 in Database by Vaani
• 7,070 points
1,876 views