有没有办法在Slick中执行这样的查询:
"select * from foo where id IN (select other_id from bar where status = 'damaged')"
Run Code Online (Sandbox Code Playgroud)
谢谢
是的:
进口:
import scala.slick.jdbc.{ GetResult, StaticQuery => Q }
import Q.interpolation
结果以及结果的转换:
case class FooResult(id: Int, name: String)
implicit val getPersonResult = GetResult(r => FooResult(r.<<, r.<<))
您的查询:
val status = "damaged"
val q = Q.query[String,FooResult]("select * from foo where id IN (select other_id from bar where status = ?)")
val result = q.list(status)
| 归档时间: |
|
| 查看次数: |
826 次 |
| 最近记录: |