DataStax Support Forums » Topic: Querying with composite keyshttp://www.datastax.com/support-forums/topic/querying-with-composite-keys
Software, Support, and Training for Apache Cassandraen-USSun, 02 Aug 2015 20:58:44 +0000http://bbpress.org/?v=1.0.3qhttp://www.datastax.com/support-forums/search.php
alexliu on "Querying with composite keys"http://www.datastax.com/support-forums/topic/querying-with-composite-keys#post-9773
Tue, 09 Apr 2013 11:21:06 +0000alexliu9773@http://www.datastax.com/support-forums/<p>The last column of the primary key can only has range operator for the composite key. The other columns of the primary key should use equal operator</p>
<p>Check the following link</p>
<p><a href="http://www.datastax.com/dev/blog/whats-new-in-cql-3-0" rel="nofollow">http://www.datastax.com/dev/blog/whats-new-in-cql-3-0</a>
</p>Uday on "Querying with composite keys"http://www.datastax.com/support-forums/topic/querying-with-composite-keys#post-9771
Tue, 09 Apr 2013 10:50:01 +0000Uday9771@http://www.datastax.com/support-forums/<p>Using datastax 3.0.</p>
<p>Connected to Test Cluster at localhost:9160.<br />
[cqlsh 2.2.0 | Cassandra 1.1.9.1 | CQL spec 3.0.0 | Thrift protocol 19.33.0]<br />
Use HELP for help.</p>
<p>Using above cql, created a table t0 with composite key (col1, col2, col3)</p>
<p>I am able to do the following :</p>
<p>select * from t0 where col1 = 'abc'<br />
select * from t0 where col2 = 'def'</p>
<p>Querying on 'col3' alone is giving an error.<br />
select * from t0 where col3 = '123'<br />
Bad Request: PRIMARY KEY part col3 cannot be restricted (preceding part col2 is either not restricted or by a non-EQ relation)<br />
Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.</p>
<p>What is the difference between querying on 'col2' alone and 'col3' alone ?<br />
I would have thought querying on 'col2' also should error out.</p>
<p>Thanks
</p>