Back

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

Will it be possible to combine LIKE and IN in a SQL Server-Query?

So, that this query

SELECT * FROM table WHERE column LIKE IN ('Text%', 'Link%', 'Hello%', '%World%')

Finds any of these possible matches:

Text, Textasd, Text hello, Link2, Linkomg, HelloWorld, ThatWorldBusiness

1 Answer

0 votes
by (12.7k points)

So, the IN statement creates a series of OR statements.

SELECT * FROM table WHERE column IN (1, 2, 3)

Is effectively

 SELECT * FROM table WHERE column = 1 OR column = 2 OR column = 3

And sadly, that's the route you will have to require together with your LIKE statements

SELECT * FROM table

WHERE column LIKE 'Text%' OR column LIKE 'Hello%' OR column LIKE 'That%'

 Interested in SQL ? Check out this SQL Certification by Intellipaat.

Related questions

0 votes
1 answer
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jan 2, 2021 in SQL by Appu (6.1k points)

Browse Categories

...