Web Analytics Made Easy -
StatCounter Update Comment in field in table? - CodingForum

Announcement

Collapse
No announcement yet.

Update Comment in field in table?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Update Comment in field in table?

    Hello, if I create a table using a script like

    Code:
    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

  • #2
    ALTER TABLE images ALTER type COMMENT = 'Your new comment'

    possibly?
    My thoughts on some things: http://codemeetsmusic.com
    And my scrapbook of cool things: http://gjones.tumblr.com

    Comment


    • #3
      Thanks for the reply.

      Here is what I tried as a test

      Code:
      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

      Code:
      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

      Comment


      • #4
        maybe 'CHANGE COLUMN' or 'MODIFY COLUMN' in place of ALTER?
        MySQL seems to have a number of similar terms :|
        My thoughts on some things: http://codemeetsmusic.com
        And my scrapbook of cool things: http://gjones.tumblr.com

        Comment


        • #5
          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.

          Code:
          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.';

          Comment


          • #6
            THank you all for the replies.


            guelphdad, I tried

            Code:
            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,
            Code:
            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.

            Comment

            Working...
            X