convert 2 select in db_select I have this query in SQL

select * 
from node n, node_collection_data nc
where n.nid = nc.nc_child_nid
and 
nc.nc_parent_nid = (select nc_parent_nid
from node_collection_data
where nc_child_nid=17)


This is what I got so far:

 $query -&gt; join('node_collection_data', 'nc', 'n.nid =
 nc.nc_child_nid'); $query-&gt;condition('type', $node-&gt;type)
       -&gt;condition('status', 1)
       -&gt;condition('n.nid', $node-&gt;nid, '!=')
       -&gt;condition(db_or()
       -&gt;condition('n.language', array($language-&gt;language, LANGUAGE_NONE), 'IN')
         -&gt;condition('n.language', $node-&gt;language, '=')
       )
       // get nc_child_id
       //-&gt;join('node_collection_' . $sort, $sort, 'n.nid = ' . $sort . '.nc_child_id')
       -&gt;fields('n', array('nid', 'title'))
       -&gt;fields('nc',array('nc_parent_nid')) // select nc_parent_id


I am trying to convert the last part.

nc.nc_parent_nid = (select nc_parent_nid from node_collection_data where nc_child_nid = 17)


How can I convert it to db_select()?
You need to search for db_select using subquery.

Look the below links to get some idea. 

Using db_select with subqueries

db_select condition with subquery