caassandra:同一列上的多个条件

时间:2016-10-19 10:53:28

标签: cassandra cqlsh

创建表格:

CREATE TABLE notifications (
  id uuid PRIMARY KEY,
  user_id bigint,
  received_datetime timestamp,
  );

cqlsh:

select count(*)
  from notifications
  where received_datetime >='2016-10-11 00:00:00'
    and received_datetime >='2016-10-18 00:00:00'
  ALLOW FILTERING;

错误: -

InvalidRequest: Error from server: code=2200 [Invalid query] message="More than one restriction was found for the start bound on received_datetime"

1 个答案:

答案 0 :(得分:0)

我猜你真正想要的是以下查询:

select count(*) from notifications
    where received_datetime >='2016-10-11 00:00:00' 
    and received_datetime <='2016-10-18 00:00:00' 
    ALLOW FILTERING;

否则,您可以通过选择更严格的条件将两个下限条件合并为一个:

select count(*) from notifications
    where received_datetime >= '2016-10-18 00:00:00'
    ALLOW FILTERING;