checking presence of table columns in mysql

Kezdőlap
Csatolmányok:
Üzenet email-ben
+ (text/plain)
Üzenet törlése
Válasz az üzenetre
Szerző: Lynn David Newton
Dátum:  
Tárgy: checking presence of table columns in mysql
Mike> /_Does anyone know of a SQL based way to check for
Mike> /_the existence of a particular column by name?


Mike> Hmmm, have you tried looking in the array:


Mike> my $names = $sth->{NAME} ;


Your suggestion is a bit minimalist, but was sufficient
for me to discover that this works:

  $sth = $dbh->prepare("select * from tablename");
  $sth->execute;
  # my $names = $sth->{NAME};
  for ($i=1; $i <= $sth->{NUM_OF_FIELDS}; $i++) {
      print "Column $i is called $sth->{NAME}->[$i-1]\n";
  }


Shazam. Thanks a bunch.

--
Lynn David Newton
Phoenix, AZ