It's unclear whether this should really be here in Coding or in the Datatbase forum so I'll put it here...I'll try to make this as simple to understand as is possible.
I need to compare records in a table and group them together. In addition to individual id's they will all have a common lid as well. They will be grouped by lid.
Based upon the lid the records should be output in a particular order - 1, 2, 3, 4 (they will have a field that determines their order. So, in essence the output will look like:
lid = 1
record 12 lid=1 oid=1
record 21 lid=1 oid=2
record 9 lid=1 oid=3
record 100 lid=1 oid=4
lid=2
record 98 lid=2 oid=1
record 23 lid=1 oid=3
It is possible that some of the oid's won't even exist though so I'll need to look for them in array.
As best as I can see, I'll need a number of queries to pull this off:
1 - get the activec lid's
2 - query for each group of records that have equal lid inside of the lid loop
Normally, I don't like using a query inside of a loop but I'm not sure about the alternative route. Grouping my results won't do it.
The only other way I see, AND THIS IS GIST OF THIS QUESTION, would be to use two queries - one for the lid and one for ALL the records. Then, I could create arrays of both - but I would need to loop through the array many times over. What is more efficient (with alot of records) - to recycle the array or put a query inside the loop?
Not sure how I want to do this yet - I'd appreciate any good ideas.
Merci...