I'm not sure about using it in a SimpleStatement in the Java driver (you
might need to test this), but the QueryBuilder does have support for in()
where you pass a list is the parameter:

see
http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/querybuilder/QueryBuilder.html#in-java.lang.String-java.util.List-


On Tue, 11 Oct 2016 at 07:24 Ali Akhtar <ali.rac...@gmail.com> wrote:

Justin,

I'm asking how to bind a parameter for IN queries thru the java driver.

On Tue, Oct 11, 2016 at 7:22 PM, Justin Cameron <jus...@instaclustr.com>
wrote:

You need to specify the values themselves.

CREATE TABLE user (
id int,
type text,
val1 int,
val2 text,
PRIMARY KEY ((id, category), val1, val2)
);

SELECT * FROM user WHERE id = 1 AND type IN ('user', 'admin') AND val1 = 3
AND val2 IN ('a', 'v', 'd');

On Tue, 11 Oct 2016 at 07:11 Ali Akhtar <ali.rac...@gmail.com> wrote:

Do you send the values themselves, or send them as an array / collection?
Or will both work?

On Tue, Oct 11, 2016 at 7:10 PM, Justin Cameron <jus...@instaclustr.com>
wrote:

You can pass multiple values to the IN clause, however they can only be
used on the last column in the partition key and/or the last column in the
full primary key.

Example:

'Select * from my_table WHERE pk = 'test' And ck IN (1, 2)'


On Tue, 11 Oct 2016 at 06:15 Ali Akhtar <ali.rac...@gmail.com> wrote:

If I wanted to create an accessor, and have a method which does a query
like this:

'Select * from my_table WHERE pk = ? And ck IN (?)'

And there were multiple options that could go inside the IN() query, how
can I specify that? Will it e.g, let me pass in an array as the 2nd
variable?

-- 

Justin Cameron

Senior Software Engineer | Instaclustr




This email has been sent on behalf of Instaclustr Pty Ltd (Australia) and
Instaclustr Inc (USA).

This email and any attachments may contain confidential and legally
privileged information.  If you are not the intended recipient, do not copy
or disclose its content, but please reply to this email immediately and
highlight the error to the sender and then immediately delete the message.





-- 

Justin Cameron

Senior Software Engineer | Instaclustr




This email has been sent on behalf of Instaclustr Pty Ltd (Australia) and
Instaclustr Inc (USA).

This email and any attachments may contain confidential and legally
privileged information.  If you are not the intended recipient, do not copy
or disclose its content, but please reply to this email immediately and
highlight the error to the sender and then immediately delete the message.





-- 

Justin Cameron

Senior Software Engineer | Instaclustr




This email has been sent on behalf of Instaclustr Pty Ltd (Australia) and
Instaclustr Inc (USA).

This email and any attachments may contain confidential and legally
privileged information.  If you are not the intended recipient, do not copy
or disclose its content, but please reply to this email immediately and
highlight the error to the sender and then immediately delete the message.

Reply via email to