question about certificate for domain

Hi,

I would like to know if certificate for mydomain.com would work as well for www.mydomain.com and for all subdomain of example.com?

I ask this because I want to buy a certificate and I was not what domain should I ask the certificate for?