Skip to content

Possible to bind arrays, for use in e.g. IN (?) queries? #103

Answered by zombiezen
beaugunderson asked this question in Q&A
Discussion options

You must be logged in to vote

SQLite does not have a direct way of passing arrays into statements. As you've discovered, you can create a statement every time, but that ends up eating some performance because you have to compile a new statement every time. Another approach is to use the json_each function:

SELECT id, callsign FROM callsigns WHERE callsign IN (SELECT value FROM json_each(?));

And then pass in a JSON-encoded array as the single parameter.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@beaugunderson
Comment options

Answer selected by beaugunderson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #102 on May 24, 2024 15:31.