[Interest] QSQLQuery bindValue to SELECT WHERE IN

Richard Moore rich at kde.org
Tue Apr 9 18:27:45 CEST 2013


On 9 April 2013 16:57, Scott Aron Bloom <scott.bloom at onshorecs.com> wrote:
> It will depend the server backend.. However in general, I have never been
> successful (not just in Qt, at all) in binding for “lists”

That's correct, a bound parameter can only hold a single value. There
are some evil tricks you can do however, for example by binding a
string parameter then making your query do the work of splitting it
but they're pretty nasty. If you choose to go down this route then be
careful you don't inadvertently introduce an SQL injection problem.

>
> I would do a “IN (:id1,:id2,:id3)” and have multiple binds

That works, though it will reduce the effectiveness of the query cache
(assuming your database does this).

Cheers

Rich.



More information about the Interest mailing list