Reputation: 1071
This compiles:
val table1 = TableQuery[Table1]
val table2 = TableQuery[Table2]
val query = for {
(t1, t2) <- table1 joinLeft table2 on (_.dsType === _.dsType)
} yield (t1, t2)
This does not compile:
val table1 = TableQuery[Table1]
val table2 = TableQuery[Table2]
val query = for {
(t1, t2) <- table1 joinLeft table2 on (_.dsType === _.dsType && _.dsSk === _.dsSk)
} yield (t1, t2)
What's the syntax to add two conditions to joinLeft
?
Upvotes: 0
Views: 363
Reputation: 332
You can specify to which table you ask for the attributes within the on and separate by the operator &&:
val table1 = TableQuery[Table1]
val table2 = TableQuery[Table2]
val query = for {
(t1, t2) <- table1.joinLeft(table2).on((tab1, tab2) => tab1.dsType === tab2.dsType && tab1.dsSk === tab2.dsSk)
} yield (t1, t2)
Similar to this question was answered in: How to add AND to the join SLICK
Upvotes: 4