我刚接触光滑,问题困扰着我。
我想查询名为attach的表,并找到数组attach_id
中包含的b
,这是一个普通的Scala数组:
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)
任何人都可以帮助我吗?
答案 0 :(得分:1)
使用
def query = for{
a<-attaches if a.attach_id inSetBind(b)
} yield (a.url)