Results 1 to 2 of 2

Thread: auto_increment - Start at Zero ?

  1. #1
    Join Date
    Jun 2003
    Location
    Puerto de Mazarron, Spain
    Posts
    1

    auto_increment - Start at Zero ?

    Im trying to set up a table with an auto_increment field starting at "0" , but when I add the first record it is assigned a value of "1".

    What should I do - sample code follows:-

    $query="
    CREATE TABLE `$cats_table` (
    `Category_ID` int(11) NOT NULL auto_increment,
    `Cat_description` varchar(20) NOT NULL default '',
    `Cat_webpage_text` varchar(100) NOT NULL default '',
    `Hide` enum('Y','N') NOT NULL default 'N',
    PRIMARY KEY `Category_ID`(`Category_ID`)
    ) TYPE=MyISAM COMMENT='Straight Listings Cats Table' AUTO_INCREMENT=0
    ";

    ------------------------------
    Then:-

    $query="
    INSERT INTO `$cats_table` (`Category_ID`, `Cat_description`, `Cat_webpage_text`, `Hide`) VALUES (0, 'Reserved', 'Reserved', 'Y')
    " ;

    --------------------------------

    The value "0" is not inserted ...

    Oddly, phpMyAdmin can subsequently change the table successfully using the same syntax.

    Thanks,


  2. #2
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145
    That is a MySQL 'feature' and you need to work around it.

    Reference: http://www.geocrawler.com/archives/3...9/5/0/2172199/

    Cheers

Posting Permissions

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