How does green plant get glucose it needs?

It takes nutrients from the dirt and also water and then uses photosynthesis to convert it to the type of sugar that it needs