MySQL Forums
Forum List  »  General

autoincrement for composite key
Posted by: Aditi Andurkar
Date: July 29, 2013 03:44AM

Hello all,

I have created a table data having composite key (id1,id2,id3). I want to autoincrement id3 but tht should depend on id1, id2. For example,
id1 id2 id3
1 1 1
1 1 2
1 1 3
1 2 1
1 2 2
1 1 4
As you can see, as soon as any of id1 or id2 changes id3 starts from 1.
Can anyone tell me how to write create table query for this scenario?

Waiting for a reply.
Regards,
Adi

Options: ReplyQuote


Subject
Written By
Posted
autoincrement for composite key
July 29, 2013 03:44AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.