Custom join with an external database I am trying to join two tables on the same database, db2. I am trying to join tablename to tablename2 using the condition tablename.ItemID = tablename2.ItemID. While the values from tablename are selectable from a view, those from tablename2 aren't.
Do I need to specify in what database tablename2 is?
/** 
* Implementation of hook_views_data
*/

function  mydatabase_views_views_data() {
  $data['tablename']['table']['group'] = t('Title name');
  $data['tablename']['table']['base'] = array(
    'field' =&gt; 'ItemID',
    'title' =&gt; t('db2'),
    'help' =&gt; t('Autoincremented ID field, to enable views integration'),
    'database' =&gt; 'db2',
    'weight' =&gt; -10,
  );

  $data['tablename']['table']['join'] = array(
    'deals_addon' =&gt; array(
      'left_field' =&gt; 'ItemID',
      'field' =&gt; 'ItemID',
    ),
  );

  $data['tablename']['ItemID'] = array(
    'title' =&gt; t('Item ID'),
    'help' =&gt; t('Item ID'),
    'field' =&gt; array(
      'handler' =&gt; 'views_handler_field',
      'click sortable' =&gt; TRUE,
    ),
    'sort' =&gt; array(
      'handler' =&gt; 'views_handler_sort',
    ),
    'filter' =&gt; array(
      'handler' =&gt; 'views_handler_filter_string',
    ),
    'argument' =&gt; array(
      'handler' =&gt; 'views_handler_argument_string',
    ),
  );

  $data['tablename']['ItemInfo'] = array(
    'title' =&gt; t('Item Info'),
    'help' =&gt; t('Item Info'),
    'relationship' =&gt; array(
      'base' =&gt; 'tablename2',
      'base_field' =&gt; 'ItemID',
      'handler' =&gt; 'views_handler_relationship',
      'label' =&gt; t('Label'),
      'title' =&gt; t('Title'),
      'help' =&gt; t('Help'),
    ),
  );
  return $data;  
}
Some time ago (D6) I was facing the same problem but then I could not find a solution. I ended up creating database views in my original db looking to the tables of the second db. This way, I was joining tables in default drupal db, which is easy. I dont know the exact changes in the api from d6 -> d7, but this might be an easy solution for you if you cannot solve it other way.