You can't use the "?" placeholder in that way with an IN clause.
If you want to use the "?" placeholder then your query should look like this:
$_query = "SELECT \"Component Name\" FROM SQLABB WHERE id IN (?,?)" ;
And you subsitute in the individual list members.
Obviously if you have an unknown number of entries in the IN clause then it because a bit harder to dynamically create your query syntax. But not impossible.
many thanks indeed Wim,
so I just need to concatenate the values into the query ...
Many thanks indeed for your swift response
1 of 1 people found this helpful
There are a few "tricks" to using IN. Wim pointed out one (each value gets a "?")
You can use variables, but do not put the "( ... )" into the variable:
$var = "1,2,4,3,6"
"WHERE abc IN ( ? )"
"WHERE abc IN( " & $var & ")" // my preference
the deal is that FM/ExecuteSQL will determine if the value of the parameter is a number and NOT quote when evaluated
or single quote the value if text when evaluated.
so, obviously, it has trouble with a string of values (comma-delimited as needed for the IN part of the clause).
thus my preference is to use the $var as a concat and I handle what gets single quotes or not.
this is easy if the values are hard-coded. it gets trickier when it's dynamically-build list of values to be used with IN.
Another way to handle:
"WHERE abc IN ( SELECT .... )" // A nested select to get the values. this may or not work for you.
so I still prefer to get the values and use them as stated above.
A few articles that may help:
read the comments, too!
(there are links to other articles.
Thanks very much Beverly - the articles are a great help.