编译:
val table1 = TableQuery[Table1]
val table2 = TableQuery[Table2]
val query = for {
(t1, t2) <- table1 joinLeft table2 on (_.dsType === _.dsType)
} yield (t1, t2)
不编译:
val table1 = TableQuery[Table1]
val table2 = TableQuery[Table2]
val query = for {
(t1, t2) <- table1 joinLeft table2 on (_.dsType === _.dsType && _.dsSk === _.dsSk)
} yield (t1, t2)
为joinLeft
添加两个条件的语法是什么?
答案 0 :(得分:3)
您可以指定您在哪个表格中询问属性,并由运营商&amp;&amp;分隔:
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)
与此问题类似,答案如下: How to add AND to the join SLICK