SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru phantom007's Avatar
    Join Date
    May 2008
    Posts
    725
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Question MySQl Table Crashing for no reason

    HI

    I have a table

    Code:
    CREATE TABLE `poll_results` (                                                                                                      
                    `id` int(5) unsigned NOT NULL auto_increment,                                                                                    
                    `poll_id` int(5) default NULL,                                                                                                   
                    `poll_choice_id` int(5) default NULL,                                                                                            
                    `hits` int(5) default '0',                                                                                                       
                    `status_id` tinyint(2) default '1',                                                                                              
                    PRIMARY KEY  (`id`),                                                                                                             
                    KEY `FK_poll_results` (`poll_id`),                                                                                               
                    KEY `FK_poll_results_choice` (`poll_choice_id`),                                                                                 
                    KEY `FK_poll_results_status` (`status_id`)                                                                                       
                  ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC

    I am running this command to insert 3 records in my new table

    Code:
    INSERT INTO `poll_results` (`hits`, `status_id`, `poll_id`, `poll_choice_id`) VALUES (0, 1, 1, 3);
    INSERT INTO `poll_results` (`hits`, `status_id`, `poll_id`, `poll_choice_id`) VALUES (0, 1, 1, 2);
    INSERT INTO `poll_results` (`hits`, `status_id`, `poll_id`, `poll_choice_id`) VALUES (0, 1, 1, 1);

    All goes well until I fire this command, my table "poll_results" crashes...

    Code:
    UPDATE `poll_results` AS `PollResult`  SET `PollResult`.`hits` = 1;
    I get this error

    Code:
    Table 'poll_results' is marked as crashed and should be repaired


    Why on earth the mysql table crash only to update 3 records?

    MySql Version is 5.0.45-community-nt


    Pls someone suggest.


    Many thanks

  2. #2
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Silly question perhaps, but why are you inserting with hits=0 then updating the entire table to hits=1 ?

    this is how I'd update it

    UPDATE poll_results
    SET hits=1;

    Have you tried this, remembering that ALL values of hits would then be set to 1.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •