Can I do something like this:
select * from mytable m where m.group_id in (?)
... and pass in a list or array of arguments to be expanded in to my parameter, ie:
select * from mytable m where m.group_id in (1,2,3,4)
Specifically, I'm using Spring and the JdbcTemplate/SimpleJdbcTemplate classes.
You can do it by using NamedParameterJdbcTemplate.
With your sample it would go something like:
NamedParameterJdbcTemplate db = ...;
List paramList = ...;
Map idsMap = Collections.singletonMap("ids", paramList);
db.query("select * from mytable m where m.group_id in (:ids)", idsMap);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With