MySQL Forums
Forum List  »  InnoDB

Help with MySQL Command
Posted by: Predrag Zivanovic
Date: August 11, 2015 12:32PM

Hallo,

One question: I had a table (InnoDB) like:

myid int(6) not null auto_increment primary key,
OrderNum int(5) not null,
Ammount double(15,2) default 0

Data example:

myid____OrderNum_____Ammount

1_______1001_________100
2_______1001_________200
3_______1002_________150
4_______1002_________250
5_______1002_________300
... etc ...

Now, I have changed structure, drop field "myid" and add new field SerialNum to have OrderNum + SerialNum as Primary key:

OrderNum int(5) not null,
SerialNum int(3) not null,
Ammount double(15,2) default 0,
Primary Key (OrderNum, SerialNum)

I want my new data to look like:

OrderNum____SerialNum____Ammount

1001________1____________100
1001________2____________200
1002________1____________150
1002________2____________250
1002________3____________300
... etc ...

My Question is: How can I assign (by MySQL commands) values to field SerialNum to auto increment WITHIN OrderNum ?

Any help ?

Options: ReplyQuote


Subject
Views
Written By
Posted
Help with MySQL Command
1389
August 11, 2015 12:32PM
653
August 15, 2015 09:16AM


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.