need the list of possible values of a column

Hi, MySQL and Perl newbie here. Please don't hurt me! :)

I'm trying to get information, from within a Perl script, about a
column in one of my tables. It's a "set" type, and I need to know
what the order is for the list of possible values.

Ex: I have a column called "subjects" in one of my tables, whose
type is "set". The possible values of this column is a list that
looks like this:

"school",
"parent",
"sibling",
"friends",
"drugs",
"money",
"sports",
"movies",
"videogames",
"homework",
"teachers"

How would I obtain this list from a perl script?

Thanks,
J. Wermont

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules [at] m .gmane.org
J Wermont [ Do, 10 Februar 2005 03:07 ] [ ID #635546 ]

Re: need the list of possible values of a column

Hi,
You should get the values with something like

my $sth = $dbh->column_info(undef, 'your_database', 'your_table', '%');
my $row = $sth->fetchall_hashref('COLUMN_NAME');
my $listofvalues = $row->{your_columnname}->{mysql_values};
print "your set was: " . join (",", [at] {$listofvalues});

best regards Christoffer


On Wed, 9 Feb 2005 18:07:17 -0800, J Wermont <jwermont [at] sonic.net> wrote:
> Hi, MySQL and Perl newbie here. Please don't hurt me! :)
>
> I'm trying to get information, from within a Perl script, about a
> column in one of my tables. It's a "set" type, and I need to know
> what the order is for the list of possible values.
>
> Ex: I have a column called "subjects" in one of my tables, whose
> type is "set". The possible values of this column is a list that
> looks like this:
>
> "school",
> "parent",
> "sibling",
> "friends",
> "drugs",
> "money",
> "sports",
> "movies",
> "videogames",
> "homework",
> "teachers"
>
> How would I obtain this list from a perl script?
>
> Thanks,
> J. Wermont
>
> --
> MySQL Perl Mailing List
> For list archives: http://lists.mysql.com/perl
> To unsubscribe: http://lists.mysql.com/perl?unsub=christoffer.vig [at] gmail.com
>
>

--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules [at] m .gmane.org
Christoffer Vig [ Do, 10 Februar 2005 10:12 ] [ ID #635866 ]
Datenbanken » gmane.comp.db.mysql.perl » need the list of possible values of a column

Vorheriges Thema: ANN: Gtk2::Ex::DBI-0.7
Nächstes Thema: RedHat E3/MySQL 4.1.9/ - can not install DBD-MySQL 2.9004