Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter query to set value of IN clause

Status
Not open for further replies.

GerryGoldberg

Technical User
Apr 12, 2001
55
My query is:
SELECT * FROM tblA WHERE billMonth IN ('JAN-03','FEB-03','MAR-03')

I would like to be able to use a parameter query to replace the contents of the IN clause, but everything I try results in either an error, or selects no records. I have tried:

SELECT * FROM tblA WHERE billMonth [range]
where I entered "IN ('APR-03','MAY-03','JUN-03')"

I also tried:
SELECT * FROM tblA WHERE billMonth IN ([range])
where I entered " 'APR-03','MAY-03','JUN-03' "

Neither of these worked. What am I doing wrong?

Thanks,

Gerry Goldberg

 
You can do it with a hard-code number of IN parameters:

SELECT Employees.LastName, Employees.FirstName
FROM Employees
WHERE (((Employees.FirstName) In ([value1],[value2])));


But based on what you've shown, why not use a date range:


SELECT Orders.OrderDate
FROM Orders
WHERE (((Orders.OrderDate) Between [start] And [stop]));

Turn your headache into my project!
Jeffrey R. Roberts
Insight Data Consulting
Access and SQL Server Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top