Find the sub site id from the My sql db?

Hi friends,

         I am new to php. I want to create interface like i have lot of sub sites in my main site like, etc.. 
        So i need to find the site url and using that site url i need to find subsite id in table and based on that id i need to display the information related to that site.
     Is there any simple way to do this other than the url comparison ?
Sponsor our Newsletter | Privacy Policy | Terms of Service