I came across the same issue as the author of this question (PreparedStatement IN clause alternatives?), and wondered if using mysql's REGEXP
would be an elegant way of getting the same functionality of IN
while using only one PreparedStatement
for varying number of values to match? Some example SQL here to show what I am talking about:
SELECT first_name, last_name
FROM people
WHERE first_name REGEXP ?
Multiple values could be supplied using a string like "Robert|Janice|Michael"
. I did not see REGEXP
mentioned anywhere in that post.