问题
I am trying to learn cassandra. I am using windows community edition (2.0).
My table schema is:
CREATE TABLE test.TestTable2 (
PK1 int,
PK2 int,
CK3 int,
CK4 int,
Dump text,
PRIMARY KEY ((PK1,PK2,CK3),CK4)
);
I want to query the dump value for (PK1=1 and Pk2 =2 and Ck3 =5 and CK4 in (4,5)) or (PK1=2 and Pk2 =2 and Ck3 =5 and CK4 in (4,5))
.
I am unable to use or condition , can someone suggest how can I do that in CQL
回答1:
There is no support for OR
operator: what you'd like to do is hit 2 partitions so it must be done by two different queries.
Query 1: (PK1=1 and Pk2 =2 and Ck3 =5 and CK4 in (4,5))
Query 2: (PK1=2 and Pk2 =2 and Ck3 =5 and CK4 in (4,5))
You can implement the "short circuit" by yourself: perform at first the query you'd expect to have bigger possibilities to retrieve the result -- If you got the result stop your process, if not perform second query.
来源:https://stackoverflow.com/questions/26309198/cassandra-cql-or-operator