The stupid question is the question not asked | |
PerlMonks |
Re: For loop suggestionsby roboticus (Chancellor) |
on Jan 11, 2013 at 11:45 UTC ( [id://1012867]=note: print w/replies, xml ) | Need Help?? |
Ah, ignore me. I didn't read the original post closely enough, and answered the wrong question. If you mean SQL database when you say database, then you can ask the database directly with something like:
Typically, database engines keep statistics about table columns so they can optimize queries, so the database engine many not even have to scan through the table to find all the values. On the other hand, if you're using a flat file, or a data structure in memory, your approach is almost good. But rather than scanning all possible values, you could just scan the records and track the minimum and maximum values:
...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|