OK, let me just kick this about a bit first.
for school we need to create a light. I want my light to have a solar cell, battery and the mains as the input energy.
Is there a way to make a circuit which when plugged into the mains, turns on the light and charges the battery at the same time,
Yes, it is very easy.
but when there isn't a power supply from the mains, it charges the battery using solar energy?
Yes, that is easy also.
But when using solar power, do you want the light to be on? Your specification does not state whether it does or not.
Alternatively, why not charge the battery from solar and switch to charging from the mains when there is no sunlight?
In order to control which input power to use, I was thinking of using a switch.
That is one way of doing it.
Alternatively, you could use a few diodes.
Here are the components I was going to use. I am not sure if the light will work.
~9v bulb
~20v solar cell
-battery
-3 way switch.
You don't mention the mains charger.
Why a 9v lamp?
Are you expecting to use a 9v battery as used to power a little radio?
This may be OK for a demonstration piece, but not for a practical working system.
So is all of the above possible or is it too far fetched for a beginner?
Yes it is possible for a beginner, but as with most things - the devil is in the detail.
If I were building this as a real project, there are things which I would do which I would not advocate for a beginner (like having the solar, switch the mains input for the charger).
JimB