incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DuyHai Doan <doanduy...@gmail.com>
Subject Re: Using "IN" with the Datastax driver (2.0-??)
Date Mon, 10 Feb 2014 22:55:07 GMT
Hello Jacob,

 You can try the bind marker for variadic param (new feature):

PreparedStatement p = session.prepare("select log_entry from log_index
where keyword *IN* ?");
session.execute(p.bind(Arrays.asList("keyword1","keyword2",...));

Regards

 Duy Hai DOAN


On Mon, Feb 10, 2014 at 11:50 PM, Jacob Rhoden <jacob.rhoden@me.com> wrote:

> Hi Guys,
>
> Im experimenting with using IN to reduce the number of quires I have to
> execute. The following works in CQL:
>
> i.e select log_entry from log_index where keyword in ('keyword1',
> 'keyword2', 'keyword3', etc...);
>
> So I now want to work out how to convert this:
>
> PreparedStatement p = session.prepare("select log_entry from log_index
> where keyword=?");
> session.execute(p.bind(keyword.toLowerCase())
>
> To take a variable number of inputs, something like this???
>
> PreparedStatement p = session.prepare("select log_entry from log_index
> where keyword in (...)");
> session.execute(p.bind(....))
>
> Thanks,
> Jacob
>

Mime
View raw message