sqlite - Prepared statements and the IN expression -
I have a database where users can search for records that contain one or more list of items. I am using IN to search, but I can not work with prepared statements, this is what I have tried to do:
SELECT * FROM tbl1 WHERE col IN ? (?)
But the statement prepared reads the list of items I have passed, how can I do this as an item?
I am using the suclite, if it makes a difference.
You can not do this way, because you can not force with an array.
You have to do it in two steps:
- Create SQL with one '?' Value per array or list
- Loop on the array or list and bind each value.
This is true despite the database.
You can not say whether sub-selection can be a better solution, but maybe it can be done to work if the price in the question was available in the second table.
Comments
Post a Comment