0

I have a val employees: List[Employee] and I need to query a table in a performant way, around these lines:

employees.foreach(employee => Select etable.id from employees_salary etable 
where etable.id == employee.id and etable.salary < 50000)

I want to filter val employees who have salary < 50000 but I want to fire one single query to database using squeryl. As I am still learning squeryl, don't know how to do this. Your help is much appreciated. Thanks in advance for help

Déjà vu
  • 28,223
  • 6
  • 72
  • 100
Scala S
  • 1
  • 1

1 Answers1

0

Assuming employees is your table mapping, ie: org.squeryl.Table[Employee], then you would just need to use squeryl's query syntax. In your case, ,it would look something like this:

from(employees)(etable => 
  where(etable.salary lt 50000) 
  select(etable)
)

You can call toList on the above if you need the resultset as a List[Employee]

jcern
  • 7,798
  • 4
  • 39
  • 47