Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Auto incrementing field till a certain condition
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 10/13/2012 :  10:02:07  Show Profile  Reply with Quote
Hi guys,
I have the following table
SNo Value Item
where Sno is a column which exists in another table also. Right now , what I need is a self incrementing field which will go on incrementing if the value of sno is a constant and then get back to 0 and start incrementing again once the value of sno changes. IS there any way to do this?

Edited by - conqueror123 on 10/13/2012 10:02:40

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/13/2012 :  13:33:49  Show Profile  Reply with Quote
I am only vaguely following what you are asking. Are you describing what should happen when you insert anew row into the table? Can you post some sample data and show examples of the conditions under which a value should be icremented and conditions under which it should be 0?

Edited by - sunitabeck on 10/13/2012 13:34:36
Go to Top of Page

Starting Member

2 Posts

Posted - 10/13/2012 :  20:56:42  Show Profile  Reply with Quote
Lets say I have four columns:
SNO|Value |Item | AUtoIncrementingField

So when I say insert into this table , and the value of SNO becomes two the value of the auto incrementing field should go back to 0. Is there any inbuilt way of doing this, or writing some code on top of mysql to achieve this. If not what other option do I have to uniquely identify each value/item belonging to a certain value of sno?

Edited by - conqueror123 on 10/13/2012 21:01:27
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000