How to write select query using simple query?

The query that I want to run using java is

select TransactionId from `AccountsT` use keys "101"

I am using Statement and do not know how to add the ‘use keys’ to the statement.
Is the following statement correct?

Statement statement = select("TransactionId").from(i("AccountsT")).add("use keys 101");

Hi @shreyagoel0911

There are methods that you can also chain to include USE KEYS to your statements; an example is below:

Statement statement = select("TransactionId").from(i("AccountsT")).useKeysValues("101");

That should produce the desired statement.

You can see more examples in the Java SDK Tests here.

Thanks

1 Like

Note for such a simple query you could just use the Sub-Document API - see: http://developer.couchbase.com/documentation/server/4.5/sdk/subdocument-operations.html#subdoc-operations

2 Likes

Thank you! This one worked just fine for me!!

I wasn’t aware of this method. I will try it! Thank you :slight_smile: