Mapping regular SQL to Drupal's Database API - using 'exists'?
I think you'll need to use a where() for the condition in the subquery, PDO will most likely quote the 'tid' and mess it up.

$sub_query-&gt;where('bt.biblio_type = b.tid');


You can cast a SelectQuery to a string to view it's SQL equivalent at any time, it helps a lot with debugging the more complex queries.

print (string) $query;