SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

conqueror123
Starting Member

India
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

sunitabeck
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

conqueror123
Starting Member

India
2 Posts

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

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  
 New 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.08 seconds. Powered By: Snitz Forums 2000