need the list of possible values of a column

need the list of possible values of a column

am 10.02.2005 03:07:17 von J Wermont

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@m .gmane.org

Re: need the list of possible values of a column

am 10.02.2005 10:12:10 von Christoffer Vig

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 (",", @{$listofvalues});

best regards Christoffer


On Wed, 9 Feb 2005 18:07:17 -0800, J Wermont 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@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@m .gmane.org