Variable Parameters

G

Gyetko

I have a variable string of data I want to use with the In() function
in a query but I can't get it to work because the In sees it as one
long string rather than a comma delimited string.

Ex:
Table1 - Field1 - Row1 = A
Table1 - Field1 - Row2 = B
Table1 - Field1 - Row3 = C

my_variable = "A,C"

SELECT Table1.Field1
FROM Table1
WHERE Table1.Field1 In (my_variable)

This query should just return rows 1 & 3, but it's reading the
parameter as In ("A,C") instead of In ("A","C"). Does anyone know how
I can make this work?

I've tried my_variable = " 'A','C' ".

If this can be done, then I have one more question. What if the
variable is empty? In ()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top