hi guys, thanks for the replies. i still haven't solved the issue, but you made me think about using an hybrid solution.
i thought about using mysql directly to manipulate fields, however it is possible that my knowledge/experience of mysql is just not good enough!
i can't take a blanket query like the one suggested as records are chronological and depend on each other.
filtering out all rows with a field2 containing '-' is not good enough as i need to substitute the value with a 'real' string which is extracted comparing field1 in either the previous or next row if the values in field 1 are the same.(if anyone has suggestions please pass them on!)
however it was very useful to consider your suggestion to consider the query with min(fieldX) as i queried all the single entries matching entries with a 'real' value.
select pKey, field1, min(field2)
from myTable
where field2 <> '-' and pKey<20000
group by field1
order by pKey,field2
what i thought after this is that i can pass the values to a much smaller 'reference' array and use another pass to check rows with the reference and substitute where necessary.
something i still have issues in grasping where is ideal to prepare and execute the queries in the loop, therefore suggestions will be much appreciated!