rsiedl has asked for the wisdom of the Perl Monks concerning the following question:
i'm pretty sure there is a way to do this straight from a select in mysql and was wondering if anybody knew it?my $join = 'customer_id'; my $sth = $global{DBH}->prepare(" select * from voice_calls ") +; my $cth = $global{DBH}->prepare(" select * from customers wher +e $join=?"); $sth->execute(); while ( my $call = $sth->fetchrow_hashref() ) { $cth->execute( ${$call}{$join} ); my $customer = $cth->fetchrow_hashref(); $cth->finish; foreach my $key (keys %$customer) { ${$call}{$key} = ${$customer}{$key} } # end-foreach push(@{$self->{RESULTS}}, \%{$call}); } # end-while $sth->finish;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: joining two tables in mysql
by Corion (Patriarch) on May 15, 2006 at 09:13 UTC | |
|
Re: joining two tables in mysql
by tinita (Parson) on May 15, 2006 at 09:15 UTC | |
|
Re: joining two tables in mysql
by UnderMine (Friar) on May 15, 2006 at 09:59 UTC |