I have a logic problem:

I have a complicated query. The main thing is that I have an ID, and for a
particular ID, I may have  between 1 to 3 rows returned. The rows returned
are variable, that is for 1 particular ID there might just be 1 row and at a
later time it may have 3 rows.

But what I need to do is print only one row for a particular ID. Please do
not suggest I do it through SQL itself, because it's after using various
aggregate functions that I have arrived at the min. result set. I need the
logic clarified, because it has me stumped. It will be simple for a
clear-thinking individual.

What I am doing is:
I maintain a set of details in say $prev_row (previous row) and another in
cur_row (current row).
The minute my cur_row detail (one unique id) doesn't match the prev_row
detail, I print out all the previous row details, and reinitialize the
various variables (all in a loop).

This works fine for all cases but fails for the last ID, because of the
logic used. Do I need to create a special case for the last one, or can
anyone suggest a better way?

-Thanks
Naintara



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

Reply via email to