Jump to content

Query database using array(i)


newcoder1010

Recommended Posts

Hi,

 

I have two single dimensional arrays.

total = 3Dim test1()redim test1(total)....Dim test2()redim test2(total).......

After assigning values to both arrays, I have the below values in both arrays:

 

test1 = A,B,C,D

test2 = 1,2,3,4

 

''' Now I am trying to query the mysql database as below:

select * from e1 where A = 1 AND B = 2 AND C = 3 AND D = 4

How can I write the query here using the values from test1 and test2 array? Note that value of total may change in different run time. Can you please help me fixing the below code? Do I need for loop?

 

I have spent lot of time but I am lost.

Select * from e1where test1(0) = test2(0) AND           test1(1) = test2(1) AND           test1(2) = test2(2) AND           test1(3) = test2(3)

Thanks,

-S

 

 

Link to comment
Share on other sites

If you want to use a loop then you can, you can assume both arrays have the same number of elements and do a loop to get each one and add it. You could also just refer to the specific elements if you know how many are in each array. What code do you have now to build the query?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...