Automatically attaching/relating one view to another view based on same value in one field
You can do this by using Contextual Filters in Views. Contextual Filters allow you to filter Views results by "Context" (context usually means the currently displayed page or currently logged in user). Assuming you want to display Contacts on a Company page:


Create a new View (admin/structure/views/add) to show content of type Contact. Make sure the Create a block checkbox is checked. If you forget and skip that checkbox, you'll have to add a Block display on the next screen.
Fill out the View so that it looks as you want it to, with the appropriate fields, etc. displayed.
Under Advanced, click to add a Contextual Filter. You're going to be filtering Contacts to display only Contacts which match a certain value for the company ID field. Scroll through the list of fields in the popup window that appears until you find the company ID field. Check the checkbox next to that field and click the Add button.
You need to define the value of the contextual filter. Under WHEN THE FILTER VALUE IS NOT AVAILABLE choose Provide default value. Choose PHP Code for the dropdown Type and enter the following code in the PHP textarea:

$node = menu_get_object('node');
if (isset($node) &amp;&amp; $node-&gt;type == 'COMPANY_CONTENT_TYPE') {
  $company_id = field_get_items('node', $node, 'COMPANY_ID_FIELD_NAME');
  if (!empty($company_id)) {
    return $company_id[0]['value'];
  }
}


Replace COMPANY_CONTENT_TYPE and COMPANY_ID_FIELD_NAME with the appropriate machine names for your company content type and the field name used to store the company ID.

This PHP loads the currently displayed node and loads the value of company ID field from that node. The value returned is used by the contextual filter to display only contacts which have a company ID field which matches this value.

You can preview the Contacts that will be displayed by manually entering a company ID in the Preview with contextual filters: input while editing the View. The preview should show only Contacts for which the company ID matches that entered value. On a live page view, this value is provided by the PHP above.
Save the View, and go to the Blocks admin page (admin/structure/block). Your new View should appear in the list of available blocks. Drag-drop the block you created into the Content region and save. Optionally configure the block and set it to only display when viewing Company nodes.


At this point you should be able to navigate to any Company node and see the list of contacts as a block, provided by Views. The PHP code entered loads the company ID from the Company node, and filters out all displayed Contacts which don't have a matching value for the company ID field of that Contact.

If you run into any issues or if I missed any steps, please comment below :-p For more information about using contextual filters, I recommend the Taming the Beast: Learn Views with NodeOne video series (parts 19-24 cover contextual filters).