How to query Nodes by a referenced Term Value (via EntityFieldQuery)? I have to query my content types (firm_unit) based on different fields conditions, and for that I came to use EntityFieldQuery.

$query = new EntityFieldQuery;

$query
  -&gt;entityCondition('entity_type', 'node')
  -&gt;entityCondition('bundle', $type = 'firm_unit')
  -&gt;propertyCondition('status', 1);


This is nice when I want to query conditions on direct content fields, like these:

$query-&gt;fieldCondition('field_name', 'value', $keyword, 'CONTAINS');
$query-&gt;fieldCondition('field_sector', 'value', $sector, '=');


It seems to be unable to directly access, and then query by, referenced contents, like names/titles and fields of referenced terms (it just can access their tids).

Which is then the way I may query my node contents based on term referenced values?

Should I query the tid before (is the _taxonomy_get_tid_from_term  func the proper to use?), and then query the content like this?

$my_tid = _taxonomy_get_tid_from_term ($term_to_match);&lt;br/&gt;
$query-&gt;fieldCondition('term_fieldname', 'tid', $my_tid);
EntityFieldQuery can not, as you have noticed JOIN tables, because it may run queries against a backend where JOIN does not make sense.

You will need bridge this gap in code, which is what your own suggestion is doing, it looks fine to me.

However, if you don't intend to run on MongoDB or some such, my personal preferance is would be to ditch EntityFieldQuery in favor of a SQL-query with db_select instead. This mostly because MySQL provides the ACID, while all the "no-sql" db's needs to break atleast one of those.