Datastax Java Cassandra driver: multiple AND statements using WHERE?

I am trying to run the following CQL statement using the latest Datastax Cassandra driver for Java:

SELECT * FROM tablename WHERE column_one=1 AND column_2=9 AND column_3=50; 

Here is what I still have (only 2 AND), but I cannot find a way to concatenate more than 2, where Clauses using and ():

 Statement select = QueryBuilder.select().all().from( "tablename").where(QueryBuilder.eq("column_one", 1)).and(QueryBuilder.eq("column_two", 9)); 

Thanks!

+5
source share
2 answers

The following should work:

  Statement s = QueryBuilder.select().all() .from("tableName") .where(eq("column_1", 1)) .and(eq("column_2", 9)) .and(eq("column_3", 50)); 

It issues the following statement:

 SELECT * FROM tableName WHERE column_1=1 AND column_2=9 AND column_3=50; 
+9
source
 Statement select = QueryBuilder.select().from("tableName"). where(QueryBuilder.eq("field","value")); 

This is another example: the eq method is contained in the CQL QueryBuilder.

0
source

Source: https://habr.com/ru/post/1215164/


All Articles