I have a table that holds a users id and a cd number, what I would like is to be able to only increment the cd number based the users id not just incrementing it every time a new cd is created
CREATE TABLE IF NOT EXISTS `cdcreation` ( `user_Id` int(3) NOT NULL, `cd_Number` int(2) NOT NULL, PRIMARY KEY (`user_Id`,`cd_Number`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
user id's start at 100, so if an id is present but no cd user 100 will get cd 1, if user 101 has no cd they get cd 1 as well, when user 100 makes next cd they get cd 2 and when user 102 gets 1st cd they get cd 1, so it increments based on user number and cd number.
Both cd number and user id will form the primary key, I would also like to be able to max the number of cd's able to be created to 5(this is not critical but a preference) I use AUTO_INCREMENT in other parts of my db but not sure how to implement it this way based on a user id.
any help much appreciated