By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,474 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,474 IT Pros & Developers. It's quick & easy.

select query using arrays

P: n/a
Hello everyone
I want to create a select query according to the values in a single
dimension array

Select * from <table Name> where <Array items>

Can anybody give me some suggestions

Mar 9 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Do you mean

SELECT *
FROM <table Name>
WHERE <Field Name> In (<Array items>)

Because if so that's pretty much what you need to do except you need to
convert your array items to a comma seperated quote delimited list.

So something like

If the array is an array of numbers
=========================
Dim strIn as string
Dim strSQl as string
dim arrValues() as string

' ..Fill up arrValues

Const JOIN_SEP = ", "

strIn = Join(arrValues, JOIN_SEP)

strSQl = "SELECT * " _
& "FROM MyTable " _
& "WHERE MyField In (" & strIn & ")"

If the array is an array of Strings
=========================
Dim strIn as string
Dim strSQl as string
dim arrValues() as string

' ..Fill up arrValues

Const JOIN_SEP = """, """

strIn = """" & 1Join(arrValues, JOIN_SEP) & """"

strSQl = "SELECT * " _
& "FROM MyTable " _
& "WHERE MyField In (" & strIn & ")"

--

Terry Kreft
"Razia" <ra*********@gmail.com> wrote in message
news:11*********************@v46g2000cwv.googlegro ups.com...
Hello everyone
I want to create a select query according to the values in a single
dimension array

Select * from <table Name> where <Array items>

Can anybody give me some suggestions

Mar 9 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.