my $stmt = "SELECT table_name FROM information_schema.tables WHERE table_schema = ? ORDER BY table_name"; my $tables = $dbh->selectcol_arrayref( $stmt, {}, ( $schema ) ); my $my_table = $tables->[0]; my $sth = $dbh->prepare( "SELECT * FROM $my_table LIMIT 0" ); $sth->execute(); my $columns = $sth->{NAME}; my $col_1 = shift @$columns; my $sth = $dbh->prepare( "SELECT $col_1 FROM $my_table" ); $sth->execute(); $sth->dump_results;