I'm not completely sure I know what you're asking. If you're wanting to put a
numerical equivalent to the possible string values, in MySQL you can use a CASE
statement, like this:
SELECT case
WHEN diploma = 'junior_high' THEN 1
WHEN diploma = 'senior_high' THEN 2
WHEN diploma = 'junior_college' THEN 3
WHEN diploma = 'university' THEN 4
WHEN diploma = 'master' THEN 5
ELSE 6
END
AS DIPLOMA
FROM Tablename
You can embed some version of that to get a numerical return from a table enumerated
as you have said, however, it still shouldn't return as you have put in your WHERE
clause. You would still have to use:
WHERE diploma = 'senior_high'
If you only wanted Senior high grads.
Is this what you are asking?
Steve Howard
-----Original Message-----
From: About-tw.com ?????? [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 02, 2001 3:16 PM
To: [EMAIL PROTECTED]
Subject: Mysql DBI Select Syntax ?
Dear All,
my $dbh = DBI->connect("DBI:mysql:xxxxx",,, { RaiseError => 1 });
my $sth = $dbh->prepare( qq{
CREATE TABLE $table_name (
diploma
ENUM("junior_high","senior_high","junior_college","university","master","doc
tor")
});
When I do the following procedure
my $dbh = DBI->connect("DBI:mysql:xxxxx",,, { RaiseError => 1 });
my $sth = $dbh->prepare( qq{ SELECT * FROM $table_name WHERE
diploma = 2 });
$sth->execute;
my $diploma = $sth -> fetchrow_array ;
$dbh->disconnect;
I can get $diploma = "senior_high"
Now here is my problem , How could I get the value of the $diploma = 2 ?
I'll really appreciated if someone can help me.