RE: List of Matches in WHERE Clause

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



There is a problem with this method with passing unlimited amount of
parameters, this SQL

Select * From TableName Where FieldName In ([Please select parameter])

When the parameter is 'A','C' it wont look for A and C, it will look for a
string 'A','B' and not seperate.

In that case i would use some code to insert a new SQL to a Query

Application.CurrentDb.QueryDefs("QueryName").SQL = "Select * From TableName
Where FieldName In (" & StrParameter & ")"
================================
I hope it's clear.

Ofer Cohen
Modiin


--
Good Luck
BS"D


"Alex Maghen" wrote:

Brilliant! I didn't know you could do that. Then in that case, let me ask you
a related question - Let's say I don't know how many of those items in the
WHERE clause I'm going to be handline and I want to pass them as parameters
to an Access Query from my application. Is there a way to provide sort of an
open-ended list parameter to an Access query? The way you can have a "params
char[] SomeList" in a C# function declaration? Know what I mean?

In any case, THANKS!

Alex Maghen
Tel Aviv


"Ofer Cohen" wrote:

You can use

select * from SomeTable
where SomeColumn In ('A','Q','Y','M')

--
Good Luck
BS"D


"Alex Maghen" wrote:

Hi. Is there a shorthand for matching a list of items in the WHERE clause?
Here's what I mean:

select * from SomeTable
where
(
(SomeColumn='A')
or
(SomeColumn='Q')
or
(SomeColumn='Y')
or
(SomeColumn='M')
)

Is there some way to make a list of things to match "SomeColumn" instead of
having to do many "OR"s?

Alex
.



Relevant Pages

  • Re: List of Matches in WHERE Clause
    ... WHERE clause I'm going to be handline and I want to pass them as ... to an Access Query from my application. ... open-ended list parameter to an Access query? ... Is there some way to make a list of things to match "SomeColumn" ...
    (microsoft.public.access.queries)
  • Re: Query Help with IF stmt
    ... >Can someone please help me with below access query to convert to sql? ... Hi Andy, ... The equivalent in proper SQL would probably be: ... UPDATE Employees ...
    (microsoft.public.sqlserver.mseq)
  • Re: heterogeneous query
    ... >This is an example of Access query to ms sql table: ... >Access which joins one field form a table stored in MS SQL Server, ... >> Regards, ... >> Manolis Perrakis ...
    (borland.public.delphi.database.ado)
  • Re: MS Access SQL > ASP SQL problem....
    ... > this code to work in ASP? ... The only way to debug a sql statement is to know what it is. ... Access Query Builder and run it without modification (unless wildcards are ... Please reply to the newsgroup. ...
    (microsoft.public.inetserver.asp.general)
  • Re: Access allergic to certain subqueries?
    ... I don't see this as a deficiency in any SQL language but a deficiency ... I never use the Access query ...
    (comp.databases.ms-access)