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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Querying a table against an Array 1

Status
Not open for further replies.

RSQUARE

IS-IT--Management
May 3, 2004
5
US
Hi
I have an Access table like

ID - NUmeric
NAME - Text

I now have in my hand a list of ID's. I need to fetch the corresponding NAMEs for ALL, repeat ALL the IDs that I have. And display it in the ASP Page. How to do it ?
This is my "Request".
Please give a "Response".

Thank you in Advance.

RR.

 
SELECT name FROM table WHERE id IN (value1, value2, value3)

That'll get everything for you.
If you need to get it from an array, then it would go something like this
dim myArray(100)

..assuming that you've put all the values in the array...

dim selectStr, sqlStr
selectStr = join(myArray,",")
sqlStr = "SELECT name FROM table WHERE id IN (" &selectStr& ")"

The key here is that you're going to use "WHERE colname IN ( , , , )"... conversely if you want to get everything not in a list you could write "WHERE colname NOT IN ( , , , )"

good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top