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
19,913 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
3,983 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
26,418 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,449 views
0 votes
1 answer

How do I perform an IF THEN statement in an SQL SELECT?

The CASE statement is the closest to IF in ...READ MORE

answered Feb 16, 2022 in Database by Vaani
• 7,070 points
1,694 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,070 points
832 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4, 2022 in Database by Vaani
• 7,070 points
558 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL server?

In SQL Server, it is possible to insert ...READ MORE

answered May 30, 2022 in Others by anisha
• 140 points
600 views
0 votes
1 answer

How can we UPDATE from a SELECT in an SQL Server

We can firstly use SELECT statement to fetch ...READ MORE

answered May 27, 2022 in Others by Avinash
• 240 points
4,751 views
0 votes
2 answers

Case in Select Statement

I think these could be helpful for ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
768 views
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

Use MySQL's FIELD() function: SELECT name, description, ... FROM ... WHERE id ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
5,354 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP