SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i have a mysql db with an ID field that auto-increments. i would like it to start at a certain number, rather than beginning at one. is this possible?

    if so, what would the sql statement be to set it? the field name is simply ID.

    thanks.

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There might be some hackish way of achieving this - but what you want to do is not in the "spririt" of MySQL.

    The idea of auto_increment is to provide a fast and easy means of creating a unique value for each row in a database to use as a primary key. Using an unsigned int as the primary key aids in database efficiency. The only significance of the auto_increment value is that it is unique - and you should not rely on it to hold any other significance. Other SQL RDMS have similar ways of creating unique identifiers for table rows.

    Its important to remember that in the relational theory there is no relationship at all between rows in a table. (hehe - some ppl here will think I'm sounding like a broken down record - but I'll keep saying this where-ever I think its appropriate ) So don't relly on an auto_increment column to give you anything else but a unique identifier for each row.

    You may want to impliment an additional column in your table to hold a value which has significance to your purpose.

  3. #3
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Sid! I have been addressing this issue for a while now. An auto-incrementing column is merely to identify the record for which it belongs. It should not be used for anything else.

    Check out this thread:

    http://www.sitepointforums.com/showt...highlight=auto
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •