while ( @row = $sth3->fetchrow ) { #GO TO FIRST RECORD OF $sth2 while ( @row = $sth2->fetchrow ) { #blah blah } }