MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 24th, 2000, 06:03 PM
bydavid bydavid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: USA
Posts: 67 bydavid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
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

Reply With Quote
  #2  
Old May 24th, 2000, 06:12 PM
bydavid bydavid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: USA
Posts: 67 bydavid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
i figured it out. sorry if this was a bother to anyone.

thanks

Reply With Quote
  #3  
Old May 25th, 2000, 07:21 AM
gbubani gbubani is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 10 gbubani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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

Reply With Quote
  #4  
Old May 31st, 2000, 09:43 PM
bydavid bydavid is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Location: USA
Posts: 67 bydavid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
thanks for the infrmation.
and thanks to devshed for probiding such helpful forums.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > autonumber field in mySQL

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap