my $sth1 = MYSQLMODULE::generate_result_set(TABLE => "employees", COLUMNS => qw(name position salary id), WHERE => "department = 'SALES'"); $sth1->execute(); while (my @employee = $sth1->fetchrow_array) { my $sth2 = MYSQLMODULE::generate_result_set(TABLE => "commission", COLUMNS => qw(total_commision), WHERE => "id = $employee[2]"); $sth2->execute(); my @commission = $sth2->fetchrow_array(); print "$employee[0]($employee[1]) = $commission[0]\n"; } ...etc...