scalaslickslick-3.0

How to search in multiple columns using the like operator in slick?


I want to get all users from the database that have the word foo either in their username or in their email address. How is this written in Slick 3.x?

select * from users where username like '%foo%' or email like '%foo%';

Solution

  • Suppose query is the search string: this does work:

    Users.filter(e => (e.username like s"%$query%") || (e.email like s"%$query%")).result
    

    Brackets are necessary between the || operator.