473,505 Members | 14,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Auto increment

23 New Member
Greetings to all,

this is my query for creating table..

Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE `books` (
  2. `serial_num` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
  3. `bk_name` VARCHAR( 200 ) NOT NULL ,
  4. `qty` INT( 10 ) NOT NULL ,
  5. `author` VARCHAR( 25 ) NOT NULL ,
  6. PRIMARY KEY ( `serial_num` )
this is my table structure...

Expand|Select|Wrap|Line Numbers
  1. +------------+------------------+------+-----+---------+----------------+
  2. | Field      | Type             | Null | Key | Default | Extra          |
  3. +------------+------------------+------+-----+---------+----------------+
  4. | serial_num | int(10) unsigned |      | PRI | NULL    | auto_increment |
  5. | bk_name    | varchar(200)     |      |     |         |                |
  6. | qty        | int(10)          |      |     | 0       |                |
  7. | author     | varchar(25)      |      |     |         |                |
  8. +------------+------------------+------+-----+---------+----------------+
  9.  
if i delete any row in this table..then the auto increment does not works properly...for e.g. if i delete 2nd row means.. then the serial number for books are 1,3,4,5..how to insert new row with serial number 2 ? how to resolve this? please help me..


_______________________
If not now,then never....

Regards,
Viji nellaiappan
Mar 4 '09 #1
3 3562
r035198x
13,262 MVP
Why is it important for you to insert at id 2? Why not let it auto increment and insert 6 instead?
Mar 4 '09 #2
Viji nellaiappan
23 New Member
@r035198x
while displaying record one by one using serial number it shows error for 2nd row..so i want to insert a record in that id..


______________
If not now,then never....


Regards,
Viji nellaiappan.
Mar 4 '09 #3
r035198x
13,262 MVP
How are you displaying the records by using serial number? You should be making sure that it works even if there is no record with id 2 in there. In general if you set a column to auto_increment, you should not be concerned about what values that column takes. It should all be managed by MySQL. If you want a column whose values you can cntrol, then define another column for that in the table and leave the auto_increment one to MySQL's amusement.
Mar 4 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
12700
by: Tom | last post by:
I am trying to store information into a table that has an auto increment field. There is currently no data in the table. Using the code below I cannot insert data into the table. I get an error...
6
5050
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
5
5136
by: Paulovič Michal | last post by:
hi all, I have problem with SERIAL field type (or sequence functionality). I have table with three columns - ID, IDS, NAME. I want auto-increment IDS grouped by ID. Example: 1, 1, Ferdo 1, 2,...
5
5098
by: vul | last post by:
In VB6 there is Auto Increment check box in Project Properties, which allow you have a new version every time you compile the project. Is there any easy way to have this feature in VB 2005? Some...
2
5503
by: john | last post by:
Is it true that if I split my access database in backend and frontend and I implement custom auto increment for the ID fields, that my database is ready to be used in a multi-user environment? I...
13
4728
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
0
4434
chumlyumly
by: chumlyumly | last post by:
Hello scripters - OS: Mac OSX Language: PHP w/ MySQL database I've created an insert page where a user inputs his info, which then goes to four different tables in a MySQL database. The...
5
8067
by: David Wright | last post by:
Hello Everyone I would be grateful if someone could help me with the automatic increment of a field on my subform called ‘Test_SrNo’. I am Using Microsoft Office 2000. The auto entry of the...
13
37538
by: BobLewiston | last post by:
Using Visual C# 2008 Express and SQL Server 2008 Express, I would like to insert new records into database "AdventureWorks", table "Person.Contact". To my surprise, this table's int-value identity...
3
4596
by: paulyXvpf | last post by:
Hello, all... Just finished a handy tutorial that has helped me understand how to auto increment and post to a web page... but its only a Web User Control passing values from VB.NET method...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.