On 3/22/2012 11:40 AM, Robert Cummings wrote:
On 12-03-22 12:34 PM, Jay Blanchard wrote:
Sorry, I just realized I didn't make the optimization explicitly
obvious... when I say "Select the children" I mean to select them
using an IN( id1, id2, id3 ) clause instead of a query for each. This
is why we build the array of parent IDs (also I wrote build an array
of "child IDs", it should have read "parent IDs" and has been fixed
above :).

SELECT DISTINCT children FROM table WHERE column1 IN(id1, id2, id3....) ?

I am sure I am not following you now. Maybe I didn't explain clearly?

What's the field for which you are selecting data? I've written this up as a parent/child relationship but it works for data/sub-data relationships also.

SELECT itemId, otherData FROM table WHERE "some condition";

SELECT itemId, subData FROM otherTable WHERE itemId IN (id1, id2, ...);

Then just link up the sub-data to the primary data in a loop and finally generate your JSON.

Does that clarify?

I must confess that the raging sinus headache and my general confusion makes this really unclear for me today. Maybe I should just set it aside for a day or so. I am super dense today.

For each level I am selecting for each parent in the level above. Let's say that level 2 contains 8 people. Level 3 contains 14 people. Only some of the 14 belong to the 8 and must be associated properly. So how can I, with one query, associate level 3' 8th, 9th and 10th people with level 2's 6th person keeping in mind that the 9th person might also belong to level 2's 4th person.

Just link up the sub-data? Place this array into a child array of the parent array? Again I apologize - maybe I should push away and let the customer know that it'll be a couple of more days.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to