|
Prev: arbeiten als krankenschwester im ausland job luebeck Event-Manager Event-Managerin arbeiten im ausland stellenangebote
Next: Using Access to analyze and report SurveyMonkey results?
From: bcap on 24 Jun 2008 11:34 Is it possible to create a SQL In statement using variables? For example, here is what can be done: SELECT Test.ID, Test.Desc FROM Test WHERE (((Test.ID) In (3,6,9,12))); But, I would like to do something like this: SELECT Test.ID, Test.Desc FROM Test WHERE (((Test.ID) In ([@TestTypes]))); ( I have a loop that will be passing the: 3,6,9,12 ) However, it does not work. Am I missing something in the syntax or is it I cannot do it this way? Any thoughts and or advice is greatly appreciated. Ray
From: timmg on 24 Jun 2008 11:56
You can pass a single parameter easiely - check help for details. However, for your example it might make more sense to build the sql statement as a text string and then execute it. Have your loop build the IN statement and concatenate the parts as required. Tim Mills-Groninger On Jun 24, 10:34 am, bcap <r...(a)patriots.com> wrote: > Is it possible to create a SQL In statement using variables? > > For example, here is what can be done: > > SELECT Test.ID, Test.Desc > FROM Test > WHERE (((Test.ID) In (3,6,9,12))); > > But, I would like to do something like this: > > SELECT Test.ID, Test.Desc > FROM Test > WHERE (((Test.ID) In ([@TestTypes]))); > > ( I have a loop that will be passing the: 3,6,9,12 ) > > However, it does not work. Am I missing something in the syntax or is > it I cannot do it this way? > > Any thoughts and or advice is greatly appreciated. > > Ray |