1

I'm new to Cassandra and I'm having a difficulty to use a simple select query on a very basic table. For example,

SELECT * FROM cars WHERE date > '2015-10-10';

on this given table:

CREATE TABLES cars ( id int primary key, name varchar, type varchar, date varchar); 

I'm able to use the = operator but not the >, < >=, <=. I have read on this subject including this article and this overflow question on the different key types, but it is still unclear to me. In the table above, date is a SIMPLE column, why can't I use the WHERE clause like I would use it in a regular RDBMS?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Alon Weissfeld
  • 1,295
  • 6
  • 21
  • 35
  • You're incorrect in saying that the = operator works on date. Will is right below where you can only use the WHERE clause on columns in the priamry key (clustering columns) – Alec Collier Oct 28 '15 at 23:41

1 Answers1

1

In Cassandra, you can only use the WHERE clause on Keys, that's why your query doesn't work.

Take a look on this article that is similar to your problem, you'll understand that Cassandra data model isn't the same as the relational one.

Will
  • 2,057
  • 1
  • 22
  • 34
  • The link http://www.planetcassandra.org/blog/we-shall-have-order/ does not work anymore. I guess the same content is in https://www.datastax.com/blog/we-shall-have-order now. – Dilini Dec 14 '20 at 08:24
  • Also on Secondary Indexes Columns. But as you said, recommended only on columns part of the Primary Key. – Carlos Iglesias Aug 11 '21 at 05:23