how do i use subquery in db_api condition? I am using drupal 7 and i would like to create subquery in condition clause with db_api. With db_query it goes something like this:

select *
from some_table_1
where some_table_1.something =
 (select max(some_table_2.something)
  from some_table_2
  where some_table_1.id = some_table_2.id
);


Among other, I was trying it with 

$query-&gt;condition('some_table_1.something', $subquery); 


and i cant get it to work.

How can i do that?
If I understand you properly you need to use a standard where clause rather than a condition in your sub query, e.g.

$subquery = db_select('some_table_2');
$subquery-&gt;where('some_table_1.id = some_table_2.id');

...

$query-&gt;condition('some_table_1.something', $subquery);