SQL Question: How to use parameterized query with SQL "IN" operator?
Permalink
I like to protect myself from SQL injection by using parameterized queries, but when I try to do this:
...I only get one row returned. I can get it to work if I do the following:
...but this does not seem like a best practice approach. What's the right way to do this?
Thanks!
Alex
...I only get one row returned. I can get it to work if I do the following:
return $db->GetAssoc('SELECT categoryID,category FROM btCategories WHERE categoryID IN ('.join(',',$idArray).')');
...but this does not seem like a best practice approach. What's the right way to do this?
Thanks!
Alex
or something similar. (the while condition might need adjusting) I believe the issue is that you need the more then one "?" since you are passing in an array with more than one value. Sorry I don't know the proper names for things, but I hope you'll get the idea.