The question is still not clear.
Is it:
1. How can I tell when a loop runs for the first time?
Yes? Then, do what sleipnir214 told you above, use a flag.
or:
2. How can I make sure that I retrieve the first row that matches my SQL condition?
Different problem - it can be handled in SQL using the "LIMIT 1" construct.