Re: Using a parameter with an IN clause?

From: Andrew Jens <andrewjens_at_hotmail.com>
Date: Thu, 24 Jan 2002 14:06:15 +1100
Message-ID: <3c4f6894_at_dnews.tpgi.com.au>


Just a quick followup,
The following site gives some information on this http://www.sqlteam.com/item.asp?ItemID=4619 I still have problems as I want to do this with a M$ Access query.

> Just a general question.
> With the following table called 'test' (ID is numeric, Name is text):
>
> Id Name
> = ====
> 1 Red
> 2 Green
> 3 Blue
>
> the following sql: 'SELECT Id, Name FROM test WHERE Id In ([p])'
> works very well if a single number is used when run (e.g p is made equal
to
> 2). Of course the query 'SELECT Id, Name FROM test WHERE Id In (1,2)'
works
> well, but when a comma-separated list is passed to the query (e.g. 1,2) it
> doesn't work.
> So the question is: why does a comma-separated list work when hard-coded,
> but not when used with a parameter?
> Thanks in advance for any assistance possible.
>
>
>
>
Received on Thu Jan 24 2002 - 04:06:15 CET

Original text of this message