Question

I have a TABLE like this:

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

Now I want to select all ids where current is equal to expected. In SQL I would do something like this:

SELECT id FROM myTable WHERE current = expected;  

But in CQL it seems to be invalid. My cqlsh returns this:

no viable alternative at input 'current'

Is there a valid CQL query to achieve this ?

Edited According to the CQL-Docs it should work but it doesn't... This is what the doc says:

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

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

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

<term> ::= "KEY"
         | <identifier>
         | <stringLiteral>
         | <integer>
         | <float>
         | <uuid>
         ;
Was it helpful?

Solution

I used the wrong docs. I'm using CQL3 and read the docs for CQL2. The correct doc says:

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

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

So it is not a valid query.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top