我有一个 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/