gagards200 Posted September 12, 2010 Share Posted September 12, 2010 hello guyz..im just new in this forum, hope that you guyz can help me with my problem..... i have a payroll database in which Employee_id is the primary key, i assign already an Employee_id for all the employees for this month, my problem is for the next month they will make a new transaction my syntax give them again a NEW Employee_id, what I want to happen is that their Employee_id that he took before was already their permanent Employee_id. Any idea guys how to solve this, Im just new in this forum, your help is highly appreciated.... Quote Link to comment https://forums.phpfreaks.com/topic/213246-how-to-insert-more-records-in-one-unique-id/ Share on other sites More sharing options...
mikosiko Posted September 12, 2010 Share Posted September 12, 2010 reading your post seems that you have a database model design problem there.... looks like you at least need: - An Employee table - a Monthly transaction table which should be related to the employee table (employee 1:n to transactions) posting your table(s) definition will help to give you a better answer Quote Link to comment https://forums.phpfreaks.com/topic/213246-how-to-insert-more-records-in-one-unique-id/#findComment-1110373 Share on other sites More sharing options...
gagards200 Posted September 13, 2010 Author Share Posted September 13, 2010 Thank you for your immediate reply.....it seems like this... Employee Table Employee_Id Field2 Field3 Field4.......etc. My Employee_Id is not auto increment, meaning i made it through randomize, when i will insert a record of course they will insert also Employee_Id, like 00000123....Now when I will insert again new record with the same data they will give me new Employee_Id, I want to save data to his Employee_Id created during first time he insert record. Really I am not sure how to fixed it, so that when I will search by Employee_Id it will give me the history of his record. If you have any idea how to make it please share it to me, thanks again and GOD BLESS.... Quote Link to comment https://forums.phpfreaks.com/topic/213246-how-to-insert-more-records-in-one-unique-id/#findComment-1110508 Share on other sites More sharing options...
kickstart Posted September 13, 2010 Share Posted September 13, 2010 Hi I agree with mikosiko. You should have a table of employees storing the common data for that employee with one record per employee. The emplyee id on this table can be generated using an auto increment (or randomly if you really must). Then have a 2nd table with its own auto increment key, with an index on the employee id and the data you need for that employee for that month. All the best Keitth Quote Link to comment https://forums.phpfreaks.com/topic/213246-how-to-insert-more-records-in-one-unique-id/#findComment-1110519 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.