How to write inner subquery in db_select() method? How can I write a subquery in Drupal 7? My query is the following:

SELECT N.nid AS n_nid
FROM   workflow_node WN
LEFT OUTER JOIN node N
ON WN.nid = N.tnid
WHERE ( WN.sid IN (SELECT WT.sid
  FROM (SELECT sid,
    Concat(',', roles, ',') AS role_stamp
    FROM workflow_transitions) AS WT
  WHERE  role_stamp LIKE '%5%')
AND N.language = "en" )
You can assign your sub query to a new variable say subquery and pass it to the db_select using

$query-&gt;condition('WN.sid', $subquery, 'IN');


You can know more about this by visiting this page.