Click to See Complete Forum and Search --> : Multidimensional array : join together??


WolfShade2k
11-18-2005, 06:06 PM
Is it possible to take two arrays that were built using "getRows()" and "splice" them together? For example:

Let's say that arrayOne is the getRows() result of the following query:
SELECT ID, Name, Age
FROM UsersGroupA

Now let's say that arrayTwo is the getRows() result of:
SELECT ID, Name, Age
FROM UsersGroupB

Is it possible to join arrayOne with arrayTwo? I've been looking all over the web, but just aren't finding it. I see lots of stuff for single-dim arrays, but not a multi-dim array join.

What say you?

Thanks,

WolfShade

PS. The above example is WAY over-simplified for what I'm actually trying to do, but it fits. I know about related-queries - can't be done for this one. Tnx.

Bullschmidt
11-24-2005, 02:11 AM
To me, your situation sounds like it might be a job for a union query (http://www.w3schools.com/sql/sql_union.asp) or subqueries.

And here is a little something I wrote to myself awhile back about using subqueries:

Example of one query (QueryB) based on the results of another query (QueryA):

QueryA = "SELECT CustID FROM tblCUSTOMERS WHERE CustName = 'A%'"

QueryB = "SELECT CustID, CustName FROM tblCUSTOMERS WHERE CustID IN (" & QueryA & ")"

But the following is even faster and allows for more than one field to be returned in QueryA:

QueryB = "SELECT tblCUSTOMERS.CustID, CustName FROM (" & strSQLA & ") AS tblSQLA INNER JOIN tblCUSTOMERS ON tblSQLA.CustID = tblCUSTOMERS.CustID"

So QueryA would include all the CustID's for customers starting with A.

And QueryB would include more fields in the customers table (i.e. not just the CustID field) for the records returned in QueryA (which was the customers starting with A).

I suppose it wouldn't hurt to always use LEFT JOIN's in QueryB and build from the tblSQLA on the left to other tables that have fields you want to return.