Hi
I have a variable $1 which hold comma separated email addresses like john@example.com,pat@example.com . I wish to pass this variable in a where clause like
As Pavanred alluded to, the easiest way -- though not necessarily the best -- is to interpolate the values yourself. You don't say what your calling language is, but something like:
sql = "SELECT something FROM whatever WHERE myColumn in (" + $1 + ")"
However, this means it's very important that you have pre-checked all the values in $1 to make sure that they are either numbers, or properly escaped strings, or whatever else it is that you need to pass but cannot be raw values supplied by a user, to avoid a SQL injection.
The other option is to make it a two-step process. First, insert the values from $1 into a temporary table, then select those values as a subquery:
WHERE myColumn in (SELECT temp_value FROM temp_table)