What am I missing? - Column missing?

Discussion in 'Databases' started by iamsgf, Jul 6, 2008.

  1. #1
    Hi,

    I am trying to install a DB, but keep getting the following error

    ERROR 1136 (21S01) at line 191: Column count doesn't match value count at row 1

    this is what it is pertaining to:

    CREATE TABLE `games` (
    `game_id` int(10) NOT NULL auto_increment,
    `game_category_id` int(10) NOT NULL default '0',
    `game_title` varchar(255) collate latin1_general_ci NOT NULL default '',
    `game_image` varchar(255) collate latin1_general_ci NOT NULL default '',
    `game_file` varchar(255) collate latin1_general_ci NOT NULL default '',
    `game_description` text collate latin1_general_ci,
    `game_featured_status` tinyint(2) NOT NULL default '0',
    `game_hits` int(10) NOT NULL default '0',
    `game_sef_title` varchar(255) collate latin1_general_ci NOT NULL default '',
    `game_today_date` date NOT NULL default '0000-00-00',
    `game_today_hits` int(10) NOT NULL default '0',
    `game_last_played` datetime NOT NULL default '0000-00-00 00:00:00',
    PRIMARY KEY (`game_id`),
    UNIQUE KEY `game_title` (`game_image`,`game_sef_title`),
    KEY `game_category_id` (`game_category_id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=3564 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;


    INSERT INTO `games` VALUES(1, 1, 'Happy Tree Friends: Flippy Attack', 'edbf4b6f6b1ac60f0ea2eb3170adf0e0_20004.png', 'edbf4b6f6b1ac60f0ea2eb3170adf0e0_20004.swf', 'The objective of this game is simple. Stay alive as long as possible. Using characters from Happy Tree Friends.', 0, 4, 'happy-tree-friends-flippy-attack', '2008-01-04', 2, '0000-00-00 00:00:00');


    Now I am counting 12 columns.

    I am sure this is one of those totally simple things that i am just blind to!!

    Thanks
     
    iamsgf, Jul 6, 2008 IP
  2. deleted-account

    deleted-account Active Member

    Messages:
    655
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    85
    #2
    I'm sure that it is supposed to be like so
    INSERT INTO 'games'(game_id, game_category_id, game_title, etc)VALUES(1, 1, 'Happy Tree Friends', 'Etc')

    I'm not too sure about the commas around 'games' try it with and without.
     
    deleted-account, Jul 7, 2008 IP
  3. Erthy

    Erthy Peon

    Messages:
    254
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As long as the data is in the proper order, the column names are optional.
     
    Erthy, Jul 7, 2008 IP
  4. iamsgf

    iamsgf Active Member

    Messages:
    982
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    85
    #4
    yup, however I still cant see where the optional issue is with what I am trying to do!
     
    iamsgf, Jul 7, 2008 IP
  5. zerofill

    zerofill Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #5
    Is it because you are trying to put a 1 in the id column when AUTO_INCREMENT=3564 ?
     
    zerofill, Jul 7, 2008 IP
  6. iamsgf

    iamsgf Active Member

    Messages:
    982
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    85
    #6
    ok, so what should be there?
     
    iamsgf, Jul 10, 2008 IP
  7. zerofill

    zerofill Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #7
    if it is auto incremented you can leave that blank...for one thing though I always specify the column names before the VALUE...you will be much happier in the long run and if you do you can try something like this:

    INSERT INTO games(game_category_id,game_title,game_image,game_file,game_description,game_featured_status,game_hits,game_sef_title,game_today_date,game_today_hits,game_last_played) VALUES(1, 'Happy Tree Friends: Flippy Attack', 'edbf4b6f6b1ac60f0ea2eb3170adf0e0_20004.png', 'edbf4b6f6b1ac60f0ea2eb3170adf0e0_20004.swf', 'The objective of this game is simple. Stay alive as long as possible. Using characters from Happy Tree Friends.', 0, 4, 'happy-tree-friends-flippy-attack', '2008-01-04', 2, '0000-00-00 00:00:00');
     
    zerofill, Jul 10, 2008 IP