How do I write a left join query?
$terms = db_select('taxonomy_index', 'ti')
  -&gt;fields('ti', array('tid', 'name'));
$terms-&gt;leftJoin('taxonomy_term_data', 'ttd', 'ti.tid = ttd.tid');
$terms-&gt;condition('vid', 2)
  -&gt;condition('nid', $nid)
  -&gt;execute();

while ($term = $terms-&gt;fetch()) {
  // $term contains the object for the taxonomy term.
}