Part of a tool I’m building involves plugging user-supplied lists of values into prepared SQLite statements. For example, where a user supplies desired sizes and colors:
SELECT * from balloons WHERE size IN ("Medium", "Large") AND color IN ("Red", "Green", "Blue");
But, in some cases, some fields are optional and can be left blank by the user. When this happens, the tool should allow any value on the column in question. For example, where a user supplies desired colors but wishes to allow any size:
SELECT * from balloons WHERE size IN (~anything~) AND color IN ("Red", "Green", "Blue");
Ordinarily, I would simply remove the constraint on size. But, since the SQL statements are precomposed with placeholders, I am hoping to avoid parsing and rewriting them on the fly.
Is there any SQLite syntax that I can put inside the IN() statement which will match any value? Alternatively, is there a different way of forming these queries to allow either a specified list of values or any value at all? Or maybe I'm approaching the entire problem the wrong way; any thoughts are welcome.
Thanks in advance!
?into however many are needed (?, ?, ?). I was hoping to avoid any more involved parsing (like finding and removing the entire IN() statement), but I suspect that's what I'll have to do.