title: Slick: How can I combine a SQL LIKE statement with a SQL IN statement
body: <p>I basically would like to replace the following code with something more "slicky":</p>
  
  <pre><code>final case class User(firstName: String, lastName: String)
  
  def dbAction(lastNameParts: Seq[String]): SqlStreamingAction[Vector[User], User, Effect]
  implicit val getUserResult =
    GetResult((r: PositionedResult) =&gt; {
      val resultSet: ResultSet = r.rs
      User(
        resultSet.getString(1),
        resultSet.getString(2)
      )
    })
  val pattern = orgIds.mkString("|")
  sql"""SELECT u.first_name, u.last_name
        FROM users u
        WHERE last_name ~* $pattern""".as[User]
  </code></pre>
  
  <p>So the resulting SQL would be:</p>
  
  <pre><code>SELECT u.first_name, u.last_name
  FROM users u
  WHERE last_name ~* '%bar|baz%';
  </code></pre>
  
  <p>So this dbAction will return an action which I can use to Query for all users having some name parts included in a list.</p>
  
  <p>So </p>
  
  <pre><code>dbAction(Seq("bar", "baz"))
  </code></pre>
  
  <p>will return an action querying for all last names containing the strings "bar" or "baz" (case insensitive). 
  I found a way to query for a single pattern</p>
  
  <pre><code>val query = for {
    user &lt;- users if user.lastName like "%bar%"
  } yield (user.firstName, user.lastName)
  </code></pre>
  
  <p>and I found a way to query for list inclusion</p>
  
  <pre><code>u &lt;- users if u.lastName.inSet(Seq("bar", "baz"))
  </code></pre>
  
  <p>but could not find a way to combine that</p>
  
  <p>EDIT: Another way to possibly solve that would be via a regular expression. Is there a way to achieve something like the following SQL statement:</p>
  
  <pre><code>select * from users where last_name ~ '[\w]*bar[\w]*|[\w]*baz[\w]*';
  </code></pre>
  
  <p>Since this is somehow a different question how to use a regex I created a different question for this:
  <a href="https://stackoverflow.com/questions/46218122/slick-is-there-a-way-to-create-a-where-clause-with-a-regex">Slick: Is there a way to create a WHERE clause with a regex?</a></p>