Getting error while joining two tables
Hi Sumit check the below query and it not showing any error. 

Use Query coder module to create any query in drupal format

Query coder Convert SQL query to Drupal Database abstraction layer code.

$query = db_select('users','u');

$query->join('users_roles', 'r', 'u.uid = r.uid'); // JOIN users_roles with users

$query->fields('u', array('name','uid')) // SELECT the field name from users
    ->condition('r.rid', 5);

$results = $query->execute();
     $rows = array();

foreach($results as $result)
  {

$rows[] = array(
    $result-&gt;uid,
    $result-&gt;name,
    );


}