cassandra中EXISTS的替代方法是什么?

时间:2019-05-05 03:28:55

标签: cql

我正在尝试用CQL重写SQLite查询。

我知道CQL中没有EXISTS关键字。我用谷歌搜索了它。但是,我找不到任何东西。

UPDATE users SET passsword = ? WHERE user_name = ? AND EXISTS(SELECT 1 FROM 
users WHERE user_name = ? AND active_status = 1)

如何在CQL中编写此查询?任何帮助表示赞赏。谢谢。

1 个答案:

答案 0 :(得分:0)

This query may be broken down to 2 queries and put an additional java logic to filter the subqueries.That will be 2 calls to database layer
Resultset rs = stmt.execute ("SELECT user_name FROM 
users WHERE active_status = 1");
while ( rs.next()){
  stmt.executeUpdate("UPDATE users SET passsword = ? WHERE user_name = "+rs.next());
}