2014-03-31 39 views
3

我有一个TABLE这样的:CQL:比较两个列的值

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查询来实现此目的?

编辑 按照定制列表,文档应该工作,但它不...这就是医生说:

<selectWhereClause> ::= <relation> ("AND" <relation>)* 
         | <term> "IN" "(" <term> ("," <term>)* ")" 

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

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

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

回答

3

我使用了错误的文档。我正在使用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> 

因此,这不是一个有效的查询。