I have a query that looks like this:
SELECT last_name,
first_name,
middle_initial
FROM names
WHERE last_name IN ('smith', 'jones', 'brown')
I need to be able to parameterize a list in an IN clause to write it as a JDBC PreparedStatement. This list can contain any number of names in it.
The correct way to do this is:
SELECT last_name,
first_name,
middle_initial
FROM names
WHERE last_name IN (?)
and then build a list of options? Or is there a better (more correct) way to do this?
source
share