#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    USA
    Posts
    67
    Rep Power
    15
    hello

    i am trying to add a field into a mysql table that will auto increment by 1 for each new record that is inputed. i tried

    create table newTable (
    id integer(11) not null auto_increment primary key,
    name varchar(20))

    when i describe the table, i get this

    Field Type Null Key Default Extra
    ----- ---- ---- --- ------- -----
    id int(11) PRI 0 auto_increment
    name varchar(20) YES NULL
    but after adding some values with the following command "insert into newTable values(1,"sdf"), i get this

    id name
    -- ----
    1 sdf
    9 dffdsdf
    3 23323dsffsdfdf

    so the table is not autoincrementing the id column
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    USA
    Posts
    67
    Rep Power
    15
    i figured it out. sorry if this was a bother to anyone.

    thanks
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    10
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by bydavid:
    hello

    i am trying to add a field into a mysql table that will auto increment by 1 for each new record that is inputed. i tried

    create table newTable (
    id integer(11) not null auto_increment primary key,
    name varchar(20))

    when i describe the table, i get this

    Field Type Null Key Default Extra
    ----- ---- ---- --- ------- -----
    id int(11) PRI 0 auto_increment
    name varchar(20) YES NULL
    but after adding some values with the following command "insert into newTable values(1,"sdf"), i get this

    id name
    -- ----
    1 sdf
    9 dffdsdf
    3 23323dsffsdfdf

    so the table is not autoincrementing the id column
    [/quote]

    Hi,

    In an autoincrement field, just type "null" as its value. MySQL will check the last inserted value and increment 1.

    ex. insert into newTable values("null","sdf")

    Bye,

    G.Bubani
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    USA
    Posts
    67
    Rep Power
    15
    thanks for the infrmation.
    and thanks to devshed for probiding such helpful forums.

Similar Threads

  1. Errcode:13 . How to solve it on MySQL + Windows 2000
    By hankycheng in forum MySQL Help
    Replies: 28
    Last Post: August 3rd, 2003, 11:05 AM
  2. Mysql field
    By Eal in forum MySQL Help
    Replies: 2
    Last Post: May 18th, 2003, 01:52 PM
  3. Replies: 2
    Last Post: May 12th, 2003, 04:04 AM
  4. Joining mySQL fields to one new field...
    By mediaworks in forum PHP Development
    Replies: 4
    Last Post: July 30th, 2001, 11:58 AM

IMN logo majestic logo threadwatch logo seochat tools logo