cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ali Akhtar <ali.rac...@gmail.com>
Subject Re: Java Driver - Specifying parameters for an IN() query?
Date Tue, 11 Oct 2016 14:24:09 GMT
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 <justin@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.rac200@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 <justin@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.rac200@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.
>
>

Mime
View raw message