Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I need some sort of way to display the values in column type by using the range of numbers. So if the range was 2-8, I would need to display all those values listed on the above table. Notice how it shows the number 4 twice , both having different values.| numbers | type | ------------------- | 2 | ac | | 3 | dc | | 4 | ca | | 4 | md | | 5 | ae | | 6 | ce | | 7 | da | | 8 | ac | ___________________
Is this the best way to do this, or is there a better way to do this in a MySQL syntax? And if it is the best way, then I wouldn't know how to calculate the number range :(!!!my $type; my $sth = $dbh->prepare_cached(<<SQL); SELECT type from dogs where number = ? SQL foreach $number (@num_range) { $sth->execute($number); $sth_x->bind_columns(undef, \$type); while ($sth->fetch) { print "$num: $type"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calculating the range between two numbers
by Zaxo (Archbishop) on Jun 24, 2005 at 06:49 UTC | |
by Anonymous Monk on Jun 24, 2005 at 06:52 UTC | |
|
Re: Calculating the range between two numbers
by anonymized user 468275 (Curate) on Jun 24, 2005 at 12:26 UTC | |
by fmerges (Chaplain) on Jun 24, 2005 at 12:41 UTC | |
|
Re: Calculating the range between two numbers
by rev_1318 (Chaplain) on Jun 24, 2005 at 07:36 UTC | |
by monarch (Priest) on Jun 24, 2005 at 07:50 UTC | |
by jhourcle (Prior) on Jun 24, 2005 at 13:45 UTC | |
by Anonymous Monk on Jun 24, 2005 at 09:31 UTC | |
|
Re: Calculating the range between two numbers
by fmerges (Chaplain) on Jun 24, 2005 at 09:41 UTC |