How to get a tax code
This is then given to the new employer in order for them to work out all the relevant details... if it's lost then you need to get in touch with your tax office.
If you are starting a first job then of course you won't have a P45 to look at or previous pay slips.
Therefore what you should do instead is be given a form called a P46 from your first employer - from here they can allocate you a tax code and work out how much tax you will owe.
This then gets processed by HMRC who will change the code if necessary based on their calculations.
The process should be fairly straightforward in summary for most people who work for other companies, as it will just involve giving them then P45 or signing the P46 and letting them work it out, you should never be asked to have to calculate what your tax code is yourself for instance!