Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Select where in problem

Author  Topic 

maderacr
Starting Member

3 Posts

Posted - 2005-11-09 : 23:08:12
Having the following info:

Table Store_Information


store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999
San Francisco $300 Jan-08-1999
Boston $700 Jan-08-1999


we key in,


SELECT *
FROM Store_Information
WHERE store_name IN ('Los Angeles', 'San Diego')

Result:

store_name Sales Date
Los Angeles $1500 Jan-05-1999
San Diego $250 Jan-07-1999

If I change ('Los Angeles' 'San Diego') to [City] get no results

SELECT *
FROM Store_Information
WHERE store_name IN [City]

Result:


Has anybody had this problem ?

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-10 : 00:48:54
What does City have?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

maderacr
Starting Member

3 Posts

Posted - 2005-11-10 : 06:34:41
[City] is a Parameter, in this case it will wait for input. I tried all the following with no luck: ('Los Angeles', 'San Diego'), ("Los Angeles", "San Diego"), (Los Angeles, San Diego), Los Angeles, San Diego. It only worked with one Parameter, if I sent Los Angeles no other options, or if I sent San Diego No other options it would select the one parameter I sent, but not both.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-10 : 06:57:18
You need to make use of Command objects to pass the parameter values to that query
How many parameters did you use?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

maderacr
Starting Member

3 Posts

Posted - 2005-11-10 : 11:10:16
The only Parameter is the [City], it will pop up a message box asking for the city. If I only type in 1 City it will work, if I try more than 1 city in the paramter it will not work. How would I use commands to pass the parameter ?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-11 : 00:46:32
Then you need to make a query like this

SELECT *
FROM Store_Information
WHERE store_name =? or store_name =?

Now you will be popped up to enter two names

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -