Is there a combination of LIKE and IN in SQL

0 votes

Unfortunately, I frequently utilize "LIKE" criteria in SQL because of databases that blatantly disregard all normalization rules. Right now, I can't change it. However, that has no bearing on the inquiry. In addition, I frequently utilize conditions like WHERE something in (1,1,2,3,5,8,13,21) to make my SQL queries easier to comprehend and more flexible.

Is it possible to combine these two things without having to create laborious sub-selects?

Instead of this, I would prefer something as simple as WHERE something LIKE ('bla%', '%foo%', or 'batz%'):

WHERE something LIKE 'bla%'
OR something LIKE '%foo%'
OR something LIKE 'batz%'

I'm working with SQL Server and Oracle here but I'm interested if this is possible in any RDBMS at all. Can someone please help me with this?

Sep 17 in Database by Kithuzzz
• 12,240 points
20 views

1 answer to this question.

0 votes

There is no LIKE & IN combination in either SQL or TSQL (SQL Server), much less PLSQL (Oracle). The fact that Full-Text Search (FTS) is the suggested substitute contributes to this.

The CONTAINS keyword is supported by both Oracle and SQL Server FTS implementations, however, the syntax is still a little different:

Oracle:

WHERE CONTAINS(t.something, 'bla OR foo OR batz', 1) > 0

SQL Server:

WHERE CONTAINS(t.something, '"bla*" OR "foo*" OR "batz*"')

I hope this helps you. 

answered Sep 18 by narikkadan
• 20,880 points

Related Questions In Database

0 votes
1 answer

What do ‘Record’, ‘Field’ and ‘Table’ mean in terms of a database?

You can refer to the following definitions ...READ MORE

answered Nov 12, 2018 in Database by Sahiti
• 6,380 points
10,436 views
0 votes
1 answer

What is a Join in terms of database?

JOINS are used to combine rows from ...READ MORE

answered Nov 13, 2018 in Database by DataKing99
• 8,240 points
413 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 in Database by Neha
• 8,920 points
1,026 views
0 votes
1 answer

What is the definition of cardinality in SQL?

Cardinality is defined as the "number of ...READ MORE

answered Feb 15 in Database by Neha
• 8,920 points
388 views
0 votes
0 answers

What is the Oracle equivalent of SQL Server's IsNull() function?

In SQL Server we can type IsNull() ...READ MORE

Sep 4 in Database by Kithuzzz
• 12,240 points
12 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 in Database by Vaani
• 7,020 points
121 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 in Database by Vaani
• 7,020 points
45 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4 in Database by Neha
• 8,920 points
216 views
0 votes
1 answer

Is there a Boolean data type in Microsoft SQL Server like there is in MySQL?

The BIT datatype can be used to ...READ MORE

answered Sep 15 in Database by narikkadan
• 20,880 points
56 views
0 votes
1 answer

What is the use of a cursor in SQL Server?

Instead of receiving a result set as ...READ MORE

answered Sep 13 in Database by narikkadan
• 20,880 points
37 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