PDA

View Full Version : Update Comment in field in table?


tripwater
10-13-2006, 06:55 PM
Hello, if I create a table using a script like

Create table images (
UserID Int UNSIGNED NOT NULL,
ImageID Int UNSIGNED NOT NULL AUTO_INCREMENT,
Name Char(50),
Description Text,
DateModified Datetime,
Active Bool,
Private Bool COMMENT 'This field is used to denote an image that should not be available in the global search engine for photogap',
Type Smallint COMMENT '0 = jpg 1 = gif 2 = bmp 3 = ico 4 = png 5 = psd 6 = flash Others can be added if needed.',
Primary Key (UserID,ImageID)) ENGINE = MyISAM
ROW_FORMAT = Default;

And say I wanted to update the COMMENT on the field 'Type' how would I do it?

Right now that field says COMMENT '0 = jpg 1 = gif 2 = bmp 3 = ico 4 = png 5 = psd 6 = flash Others can be added if needed.'

But I need to change this as things have been reworked and added and these numbers do not match up anymore.

Thanks for any help with this

GJay
10-13-2006, 07:41 PM
ALTER TABLE images ALTER type COMMENT = 'Your new comment'

possibly?

tripwater
10-13-2006, 08:00 PM
Thanks for the reply.

Here is what I tried as a test

ALTER table images ALTER Type COMMENT = '1 = jpg 2 = gif 3 = bmp 4 = ico 5 = png 6 = psd 7 = flash Others can be added if needed.';


and I got this error

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COMMENT = '1 = jpg 2 = gif 3 = bmp 4 = ico 5 = png 6 = psd 7 = flash Ot' at line 1

GJay
10-14-2006, 03:34 AM
maybe 'CHANGE COLUMN' or 'MODIFY COLUMN' in place of ALTER?
MySQL seems to have a number of similar terms :|

guelphdad
10-14-2006, 06:43 AM
you need to use CHANGE and you also have to name your column and column type again. since you are leaving the column name the same it would appear twice.

ALTER table images CHANGE Type Type smallint COMMENT = '1 = jpg 2 = gif 3 = bmp 4 = ico 5 = png 6 = psd 7 = flash Others can be added if needed.';

tripwater
11-02-2006, 06:06 PM
THank you all for the replies.


guelphdad, I tried

ALTER table images CHANGE Type Type smallint COMMENT = '1 = jpg 2 = gif 3 = bmp 4 = ico 5 = png 6 = psd 7 = flash Others can be added if needed.';

But I received the error, You have an error in your SQL Syntax near = '1 = jpg 2 = gif 3 = bmp 4 = ico 5 = png 6 = psd 7 = flash Others can be added if needed.' at line 1


SO I am assuming the single ticks are what caused this in the comment update. I tried removing the '' but still got an error. Any ideas?

Thank you again for your time.