0
我是新來的華而不實,而且問題在困擾着我。 我要查詢一個叫附加表,發現包含在數組b
這是正常的斯卡拉陣列中attach_id
:在play-slick中使用sql查詢,其功能類似於包含
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)
誰能幫助我嗎?
http://slick.typesafe.com/doc/3.1.1/sql-to-slick.html?highlight=inset#id21'。在預計一個子查詢的方法。對於內存中的Scala集合,方法.inSet可以用來代替.' – danielnixon
是的,它的工作原理謝謝你 – user1443502