Using a parameter with an IN clause?
From: Andrew Jens <andrewjens_at_hotmail.com>
Date: Thu, 24 Jan 2002 13:54:49 +1100
Message-ID: <3c4f65e5_at_dnews.tpgi.com.au>
Just a general question.
With the following table called 'test' (ID is numeric, Name is text):
Date: Thu, 24 Jan 2002 13:54:49 +1100
Message-ID: <3c4f65e5_at_dnews.tpgi.com.au>
Just a general question.
With the following table called 'test' (ID is numeric, Name is text):
Id Name
= ====
1 Red
2 Green
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 - 03:54:49 CET