8

I'm 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's what I have so far (only 2 ANDs), but I can't find a way to chain 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!

mikestaszel
  • 362
  • 1
  • 4
  • 9

2 Answers2

12

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 produces the following statement:

SELECT * FROM tableName WHERE column_1=1 AND column_2=9 AND column_3=50;
Andy Tolbert
  • 11,418
  • 1
  • 30
  • 45
0
Statement select = QueryBuilder.select().from("tableName").
where(QueryBuilder.eq("field","value"));

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

Andrea
  • 54
  • 5