SQL ENUM

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
k7faq
Forum Newbie
Posts: 1
Joined: Thu Jan 14, 2010 10:07 pm

SQL ENUM

Post by k7faq »

I need to be able to ALTER a table. The problem that I am running into is that the field is in ENUM format.

It would be really nice of someone to help point me in a direction that I can read the "ENUM" values from the table and place them into a string. An example of what I have tried is below.

The problem that I am running into is that in PHPMyAdmin shows the ENUM values when the Table Structure is viewed. Unfortunately when you run a query, such as "SELECT COUNT( * ) AS `Rows` , `class_location`
FROM `classes` GROUP BY `class_location`" within PHPMyAdmin only two of the three values are displayed and the number of records of each.

I need the ability to gather ALL of the Enumerated values in order to create an ALTER table command.

Thank you so much for your thoughts.
Steven

The following displays the same as PHPMyAdmin
$query = "SELECT `class_location` FROM `classes` GROUP BY `class_location`";
$result=mysql_query($query);
while ($pri=mysql_fetch_array($result))
{
$nowLocations=$nowLocations."'".$pri['class_location']."',";
}
echo $nowLocations;
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: SQL ENUM

Post by califdon »

Try this query:

Code: Select all

SHOW CREATE TABLE classes;
http://dev.mysql.com/doc/refman/5.0/en/ ... table.html
Post Reply