How to use condition with multiple term I try to get all the node that belong to 2 taxonomies terms (term 1 AND term 2).

I try with this :

    $select = db_select('node', 'n')
      -&gt;fields('n', array('nid','title'))
      -&gt;condition('n.status', 1);
    $select-&gt;fields('n', array('nid'));
    $select-&gt;fields('n', array('title'));
    $select-&gt;orderBy('n.title', 'ASC');
    $select-&gt;join('field_data_field_sous_theme', 'ss', 'ss.entity_id = n.nid');
    $select-&gt;condition(db_and()-&gt;condition('ss.field_sous_theme_tid', 517)-&gt;condition('ss.field_sous_theme_tid', 514));
    $results = $select-&gt;execute()-&gt;fetchCol();


or this :

$select = db_select('node', 'n')
  -&gt;fields('n', array('nid','title'))
  -&gt;condition('n.status', 1);
$select-&gt;fields('n', array('nid'));
$select-&gt;fields('n', array('title'));
$select-&gt;orderBy('n.title', 'ASC');
$select-&gt;join('field_data_field_sous_theme', 'ss', 'ss.entity_id = n.nid');
$select-&gt;condition(db_and()-&gt;condition('ss.field_sous_theme_tid', 517)-&gt;condition('ss.field_sous_theme_tid', 514));
$results = $select-&gt;execute()-&gt;fetchCol();


But there is no result.

And when i try this :

$select = db_select('node', 'n')
  -&gt;fields('n', array('nid','title'))
  -&gt;condition('n.status', 1);
$select-&gt;fields('n', array('nid'));
$select-&gt;fields('n', array('title'));
$select-&gt;orderBy('n.title', 'ASC');
$select-&gt;join('field_data_field_sous_theme', 'ss', 'ss.entity_id = n.nid');
$select-&gt;condition('ss.field_sous_theme_tid', array(517,514), 'IN');    
$results = $select-&gt;execute()-&gt;fetchCol();


I've all the nodes that belong to the term 1 OR the term 2.

I've you got an idea to solve my problem ?

Ps: sorry for my bad english, i'm french :-)
What about getting the arrays of nids for each of the tids you want to search with taxonomy_select_nodes($tid) and then intersect the lists with array_intersect. There should be a more Drupalistic way however...