cassandra - CQL:比较两列值

标签 cassandra cql cqlsh

我有一个 TABLE像这样:

    id   | expected | current
   ------+----------+--------
     123 |    25    |   15
     234 |    26    |   26
     345 |    37    |   37

现在我想全选 ids哪里current等于 expected .在 SQL 中,我会做这样的事情:
SELECT id FROM myTable WHERE current = expected;  

但是在 CQL 中它似乎是无效的。我的 cqlsh返回这个:
no viable alternative at input 'current'

是否有有效的 CQL 查询来实现这一点?

已编辑
根据 CQL-Docs 它应该可以工作但它没有......这就是文档所说的:
<selectWhereClause> ::= <relation> ( "AND" <relation> )*
                      | <term> "IN" "(" <term> ( "," <term> )* ")"

<relation> ::= <term> <relationOperator> <term>

<relationOperator> ::= "=" | "<" | ">" | "<=" | ">="

<term> ::= "KEY"
         | <identifier>
         | <stringLiteral>
         | <integer>
         | <float>
         | <uuid>
         ;

最佳答案

我使用了错误的文档。我正在使用 CQL3 并阅读 CQL2 的文档。
正确的文档说:

<where-clause> ::= <relation> ( AND <relation> )*

<relation> ::= <identifier> <op> <term>
             | '(' <identifier> (',' <identifier>)* ')' <op> '(' <term> (',' <term>)* ')'
             | <identifier> IN '(' ( <term> ( ',' <term>)* )? ')'
             | TOKEN '(' <identifier> ( ',' <identifer>)* ')' <op> <term>

所以它不是一个有效的查询。

关于cassandra - CQL:比较两列值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22761570/

相关文章:

Cassandra : DELETE doesn't work

database - 获取cassandra cql中列值相同的所有行

cassandra - 从 Cassandra cql 表中删除所有行

在时间戳列上使用等于运算符的 Cassandra 查询不起作用

cassandra - 无法创建嵌套集合数据类型

linux - 在脚本中执行 cqlsh

cassandra - 如何将 Apache Cassandra 作为服务启动?

cassandra - 允许过滤对 Cassandra 有什么影响?

c++ - Datastax Cassandra C++ 驱动程序中核心连接和 i/o 线程之间的区别

java - 为什么使用十六进制文字的 Cassandra cql 查询有效,但 textAsBinary 无效?