Multiple Drupal sites using the same code base
coleopterist is right.

Let's say you want mydomain.com and sub.mydomain.com to share the same codebase, you will have to put two folders in sites/ :


sites/mydomain.com/
sites/sub.mydomain.com/


If you want modules and themes to be available to all domains defined in sites/, all you have to do is to put them in all/ :  


sites/all/modules/
sites/all/themes/


Then, in sites/{domain}/settings.php you can redefine the databases strings like so :

$databases = array (
  'default' =&gt; 
  array (
    'default' =&gt; 
    array (
      'database' =&gt; 'database_name',
      'username' =&gt; 'user_name',
      'password' =&gt; 'p4ssw0rd',
      'host' =&gt; '127.0.0.1',
      'driver' =&gt; 'mysql',
      'prefix' =&gt; 'drupal_',
    ),
  ),
);


Note that you should launch the DrupalRoot/install.php script for each different domain to create its database tables.