在 cql for scala 中多插入
To multi insert in cql for scala
我想在第二个查询中插入第一个查询的结果,我需要知道如何在 Cassandra 查询中插入多个值Language.Please 赐教。
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
}
提前致谢
你可以尝试类似的东西
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
我想在第二个查询中插入第一个查询的结果,我需要知道如何在 Cassandra 查询中插入多个值Language.Please 赐教。
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
}
提前致谢
你可以尝试类似的东西
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