我想在第二个查询中插入第一个查询的结果,我需要知道如何在Cassandra查询语言中多插入值。请赐教。
def daomethod(seconditemtable:SecondItemTable):java.util.List[Row]={
val query=session.execute("select item from itemtable").all() //first query
val queryvalue=query.map(x=>x.getString("item")).toList.distinct //List(item1,item2,item3)
val secondquery="select * from seconditemtable where entity=? and item=? and date>=? and date<=?" //second query
val statement=session.prepare(secondquery)
val boundstatement= new Boundstatement(statement)
session.execute(boundstatement.bind(seconditemtable.entity,queryvalue,seconditemtable.date,seconditemtable.date)).all() //how to insert multiple value of firstquery in item column
}
提前致谢
答案 0 :(得分:0)
你可以尝试类似的东西
val secondquery=s"select * from seconditemtable where entity=? and item in (${queryvalue.mkString(",")}) and date>=? and date<=?"
在语句中利用cql。 关于它的更多细节https://docs.datastax.com/en/cql/3.3/cql/cql_reference/select_r.html