首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >play-slick中的sql查询,具有如下函数

play-slick中的sql查询,具有如下函数
EN

Stack Overflow用户
提问于 2016-03-13 16:39:59
回答 1查看 348关注 0票数 0

我是新手,有个问题一直困扰着我。我想查询一个名为attach的表,并找到数组b中包含的attach_id,该数组是一个普通的Scala数组:

代码语言:javascript
复制
val attaches: TableQuery[AttachTable] = TableQuery[AttachTable]
val b = Array[Int](1,2,3)

// This query works well, but I actually need the attach_id that in the array b 
def query = for {
  a <- attaches if (a.attach_id === 1)
} yield (a.url)

// If I replace it like this, it doesn't work, and I don't know why
def query = for {
  a <- attaches if (b.contains(a.attach_id))
} yield (a.url)

// This also failed, because b is Array[Int]
def query = for {
  a <- attaches if (a.attach_id in b)
} yield (a.url)

有人能帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2016-03-16 22:45:48

使用

代码语言:javascript
复制
def query = for{
  a<-attaches if a.attach_id inSetBind(b)
} yield (a.url)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35968260

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档