I have a domain (www.mydomain.com) hosted on Hosting A. How can I have the subdomain (sub.mydomain.com) to be hosted on Hosting B?
This is relatively easy to do.
Using example.com, you have:
An A record for the example.com A CNAME (as an alias) pointing www to example.com (www is a sub-domain) --where www = example.com -- or -- An A record for www.example.com
To have sub-domain.example.com you would have:
An A record for sub-domain.example.com --where the IP address is for the new host and the website domain is set-up as sub-domain.example.com within the new hosts control panel.
That should be it.