Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我一直在搜索文档,但我找不到这么简单的东西。
这个说法似乎有效
val row = MyTable.where(_.col1 === "val1").firstOption
但是这个不
val row = MyTable.where(_.col1 === "val1" && _.col2 === "val2").firstOption
如何在 where 子句中使用多个参数?
一个参数只能使用一次下划线。这是一个快捷方式:
val row = MyTable.where(x => x.col1 === "val1").firstOption
因此,在您的情况下,这应该可行:
val row = MyTable.where(value => value.col1 === "val1" && value.col2 === "val2").firstOption