my $sql = 'SELECT student_id, grade, instructor FROM student_info_table WHERE class = ? ORDER BY student_id'; my $sth = $dbh->prepare_cached($sql); $sth->execute('BUS4000'); while ( @row = $sth->fetchrow_array ) { my ( $id, $grade, $instructor ) = @row; # blah }