2014-03-31 41 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> 

因此,這不是一個有效的查詢。