How to use LIKE clause with IN caluse in Sql Server?

I want to use the LIKE clause and the IN clause together. for example: At the moment, my request is

SELECT 
   * 
FROM 
   [USER_DETAILS] 
WHERE 
   [NAME] LIKE 'Dev%' OR 
   [NAME] LIKE 'Deb%' OR 
   ......
   ......

How can I use the IN clause to achieve this? Can someone help? :)

+3
source share
2 answers

Put the parameter values ​​in the table, then use one condition JOIN, for example.

SELECT * 
  FROM [USER_DETAILS] AS U1
       INNER JOIN Params AS P1
          ON U1.[NAME] LIKE P1.param + '%';
+1
source

Agree with NullUserException - there is no such syntax. "In" is the "syntactic sugar" for an equal predicate. There is no equivalent for other operations such as>, <, so you should use OR.

0
source

Source: https://habr.com/ru/post/1756855/


All Articles