Help with 'in' queries
Hi - sorry if this has been asked, but it's kind of hard to search for!
If it helps, I'm using cloudflare's D1 database (sqlite).
What I'd like to do is the following query:
select id, tag from tags where tag in ('foo', 'bar', 'baz');
The closest I can get so far is:
const tagsAlreadyThere = await getEntriesDb(context).run(
)
But that fails if a tag has a single quote in it... I'd like to do something like a
If there's a better way to do such a query I'd be glad to find it... the nice thing about it is it's a single query, rather than querying for each tag individually.
Thanks!
If it helps, I'm using cloudflare's D1 database (sqlite).
What I'd like to do is the following query:
select id, tag from tags where tag in ('foo', 'bar', 'baz');
The closest I can get so far is:
const tagsAlreadyThere = await getEntriesDb(context).run(
Select Id, Tag from LFLGTags where Tag in (${tags.map((t) => '${t}').join(', ')}))
But that fails if a tag has a single quote in it... I'd like to do something like a
prepare statement, but I haven't been able to figure out how to do that in this case.If there's a better way to do such a query I'd be glad to find it... the nice thing about it is it's a single query, rather than querying for each tag individually.
Thanks!