Can prepared statements bind arrays for `IN (?)`
does anyone know if prepared statements can be bound with arrays? i'm trying to do a query like
db.prepare('SELECT * FROM table WHERE status IN (?)').bind(['active','expired']).all()
, would that work?5 Replies
the alternative is to generate the SQL string and then spread into the
bind()
call, but was wondering if i could avoid thatYou'd need to create the
?
's in the string based on the length of the arrayso the
?
placeholder won't automatically expand the parameter into a list?well crap 😐
ok, thanks for that answer, it's exactly what i needed
it is then.