How to map uid in users table data to the entityid in feild table to retrieve data of the users in drupal7
For the field_data_* tables, when the entity_type is node, the entity_id &amp; revision_id are the foreign keys into the node table. You can use this to JOIN into the users table.

  //@TODO: Replace field_data_* with the field table in question
  $fields = db_select('field_data_*', 'f');
  $fields-&gt;join('node', 'n', "n.nid = f.entity_id AND n.vid = f.revision_id AND f.entity_type = 'node'");
  $fields-&gt;join('users', 'u', "u.uid = n.uid");
  $new = $fields
    -&gt;fields('f')
    -&gt;fields('u',array('uid'))
    -&gt;execute()-&gt;fetchAll();