On Wed, Apr 11, 2001 at 06:09:09PM +0100, Tim Bunce wrote:
> ----- Forwarded message from Scanman 20 <[EMAIL PROTECTED]> -----
>
> From: Scanman 20 <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: nesting queries?
> Date: Wed, 11 Apr 2001 09:50:28 -0400
> I posed this question to alt.perl a while ago but never got an answer from
> anyone. Using Perl, Unix and MySQL, is it possible using DBI to nest
> database queries? I'm looking to do something like select all the records
> from one table, and then while I loop through all the records, run a second
> query inside the loop on another table in the same database. Something like
> this:
> $sth = $dbh->prepare("select * from Table1") or choke("Can't prepare
^^^^
> statement: ",$dbh->errstr);
> $rv = $sth->execute;
>
> while (($some_stuff) = $sth->fetchrow_array) {
>
> $sth = $dbh->prepare("select * from Table2") or choke("Can't prepare
^^^^
It will help to not use the same variable to store both queries. :)
Ronald