Harch84 has asked for the wisdom of the Perl Monks concerning the following question:
Now what I want to be able to do is to loop through each of the rows from this query in Perl, and to find where the service_id is the same. And make an IF statement that says when they are the same only return the row with the shortest distance. This is the part of the Perl script that brings my query into Perl:stop_reference | service_id | distance ----------------+------------+------------------ 6200200581 | 1 | 131 6200249240 | 2 | 148.32734070292 6200249230 | 2 | 247.695377429616 6200249250 | 2 | 394.507287638644 6200249220 | 2 | 394.81641303269
Im hoping someone can help me to do this? If you need anymore information please let me know. Thanks$originsql = qq{ SELECT a.stop_reference, b.service_id, distance....}; $sth = $dbh->prepare( $originsql ); $sth->execute(); $sth->bind_columns( undef, \$stops, \$service, \$distance ); while( $sth->fetch() ) {
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Help with manipulating data from a database??
by ForgotPasswordAgain (Vicar) on Jul 02, 2007 at 14:17 UTC | |
by dsheroh (Monsignor) on Jul 02, 2007 at 15:38 UTC | |
by ForgotPasswordAgain (Vicar) on Jul 03, 2007 at 08:36 UTC | |
by Harch84 (Acolyte) on Jul 02, 2007 at 15:17 UTC | |
Re: Help with manipulating data from a database??
by bobf (Monsignor) on Jul 02, 2007 at 13:55 UTC | |
Re: Help with manipulating data from a database??
by archfool (Monk) on Jul 02, 2007 at 13:55 UTC | |
Re: Help with manipulating data from a database??
by mikeB (Friar) on Jul 02, 2007 at 15:30 UTC | |
Re: Help with manipulating data from a database??
by swampyankee (Parson) on Jul 02, 2007 at 16:05 UTC | |
Re: Help with manipulating data from a database??
by johngg (Canon) on Jul 03, 2007 at 13:37 UTC |