I have a custom table with two fields I'd like to use as foreign keys to user with corresponding content fields attached to the user entity. So far I have the base table exposed to Views and showing data in preview. I have been trying to add just a single field of relationship/join at a time, so here's what I've got for that:

$data['lcm_subscription_lookup']['SID'] = array(
  'relationship' => array(
      'base' => 'field_data_field_subscription_sid',
      'field' => 'SID',
      'handler' => 'views_handler_relationship',
      'label' => t('User SID'),
$data['lcm_subscription_lookup']['table']['join'] = array(
  'field_data_field_subscription_sid' => array(
      'left_field' => 'field_subscription_sid_value',
      'field' => 'SID',

I think there's a clue in the views generated SQL with error:

{lcm_subscription_lookup} lcm_subscription_lookup
LEFT JOIN {field_data_field_subscription_sid} field_data_field_subscription_sid_lcm_subscription_lookup ON lcm_subscription_lookup.SID = field_data_field_subscription_sid_lcm_subscription_lookup.

Note that there is no field specified (empty string after "." where I'd expect 'field_subscription_sid_value') in the JOIN .. ON to the field table.

Once this is working, I'll need to also add in the other field (lcm_subscription_lookup.AddrID -> field_data_field_subscription_addrid.field_subscription_addrid_value) and then what to link to the User itself?

This https://drupal.stackexchange.com/a/137661/2114 looks really close along these lines, but I haven't make the connection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.