How to use SQL "LIKE" operator in SLICK

wassertim picture wassertim · Feb 5, 2013 · Viewed 12.3k times · Source

Maybe a silly question. But I have not found an answer so far. So how do you represent the SQL's "LIKE" operator in SLICK?

Answer

Faiz picture Faiz · Feb 5, 2013

Exactly as you normally would!

val query = for {
  coffee <- Coffees if coffee.name like "%expresso%"
} yield (coffee.name, coffee.price)

Will generate SQL like

SELECT name, price FROM coffees WHERE NAME like '%expresso%';