Hopefully I can explain this right.
Right now I have a Category column in my table. Well I am wanting to take the "Category" from varchar to ENUM so I can change the values easily.
Can I do that without losing any data?
What I have right now is the Category column has comments but the comments wont let me add anything in it.
You can see what I mean from the screenshot below.
my advice is to stay well clear of ENUM
i doubt you can make the change easily in any case
that's not a mysql problem, though
VARCHAR can take anything
i would check your application code
Ok, Much appreciated. Any ideas of how I can add like 3 more items to the comments? I can to a SQL Query but will that mess up the existing data?
i'm not sure i understand what you mean by "3 more items"
your category column can hold as many items as you can fit into 2000 characters
oh, wait a sec... you're talking about the column comments!
column comments are strictly for documentation purposes
perhaps you could explain a bit more about the table that your category column is in, and how it is to be used?
I have a site where I add products through an admin panel. The "comments" are the categories that I use for a drop down. I need to add 3 more categories to that, But this is all I can see when I go to add it.
those are the comments of the category column, correct?
they have no bearing on what values the column can hold
what you should do is create a categories table, that has one row for every allowable category value
then tie this to your items table with a foreign key
I know this is a late reply, But is there any tutorial that will show me how to do that?
CREATE TABLE categories
( category VARCHAR(937) NOT NULL PRIMARY KEY
INSERT INTO categories VALUES
( 'Automation-Controls' )
,( 'Baggers' )
,( 'Bagger-Scales' )
,( 'Bins' )
,( 'Cappers' )
,( 'Case-Erectors' )
,( 'Carton-Formers' )
,( 'Check-Weighers' )
,( 'Complete-Lines' )
,( 'Confectionary-Equipment' )
,( 'Continuous-Mixers' )
,( 'Control-Panels' )
,( 'Conveyors' )
,( 'Cookie-Lines' )
,( 'Cooling-Tunnels' )
,( 'Cutting-Slitting ' )
ALTER TABLE new_equip
ADD CONSTRAINT cat_fk
FOREIGN KEY ( category )
REFERENCES categories ( category )
I appreciate that. My issue is I have everything going into one table. "new_equip" and in that table I have a column called Category and thats where all the categories are being stored. I have no clue how to edit it with using tables ad not messing up the site.
I have attached a screenshot to help it make more sense.
did you try running the code i gave you? what happened?
This topic is now archived. It is frozen and cannot be changed in any way.