I have a table which consist of many columns and one of them is serial number. My requirement is whenever user enters the data in form and data gets added to the database but i don't want the user to enter the serial number every time. How to increment serial number in database itself?
Asked
Active
Viewed 2,160 times
-4
-
1`AUTO_INCREMENT` could help http://dev.mysql.com/doc/refman/5.7/en/example-auto-increment.html – Nicolas Filotto Oct 07 '16 at 17:29
-
See http://stackoverflow.com/questions/1915166/how-to-get-the-insert-id-in-jdbc - create an INSERT witthout the primary key which is defined as AUTOINCREMENT field, and get afterwards the generated key. – Joop Eggen Oct 07 '16 at 17:33
2 Answers
0
From the description of your project I can recommend you to do a while loop to run the program. Create a variable for the serial number with an initial value and set it to be incremented every time it passes through the loop(when the user inputs the information). You can increment the serialNumber variable doing: serialNumber++. This will bring it up by one every time it goes through the loop. This can work in case you are using JAVA.

Erick Moreno Flores
- 11
- 2
0
Why don't you use as Identity for that serial number column with auto increment property. That will auto increment every time a row is added to that table

Nirjhar Vermani
- 1,215
- 8
- 17