title: how to construct range query in cassandra?
body: <pre><code>CREATE TABLE users ( 
  userID uuid, 
  firstname text, 
  lastname text, 
  state text, 
  zip int,
  age int,
  PRIMARY KEY (userID) 
  );
  </code></pre>
  
  <p>I want to construct the following queries:</p>
  
  <pre><code>select * from users where age between 30 and 40
  
  select * from users where state in "AZ" AND "WA"
  </code></pre>
  
  <p>I know I need two more tables to do this query but I dont know how the should be?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>From Carlo's comments, I see this is the only possibility</p>
  
  <pre><code>CREATE TABLE users ( 
  userID uuid, 
  firstname text, 
  lastname text, 
  state text, 
  zip int,
  age int,
  PRIMARY KEY (age,zip,userID) 
  );
  </code></pre>
  
  <p>Now to select Users with age between 15 and 30. this is the only possibility:</p>
  
  <pre><code>select * from users where age IN (15,16,17,....30)
  </code></pre>
  
  <p>However, using IN operator here is not recommended and is anti-pattern.</p>
  
  <p>How about creating secondary Index on age?</p>
  
  <pre><code>CREATE index users_age ON users(age)
  </code></pre>
  
  <p>will this help?</p>
  
  <p>Thanks</p>