$hub_sql_cmd = "select DISTINCT $hub_stuff[$c][1] from $hub_stuff[$c][0]" ; $temp = $hub_sql_cmd . " where $hub_stuff[$c][1] = '$line2[$c]'"; $hub_sth = $hub_dbh->prepare($temp) or die "Couldn\'t prepare statement: " . $hub_dbh->errstr; $hub_sth ->execute || die "Couldn\'t execute statement"; @line = $hub_sth->fetchrow_array; #### select DISTINCT AUDCTIME from mpi_audhead where AUDRECNO = 2.