1

I have this Database API code, and I'm trying to add a sub-query to it:

$query = db_select('' . $base_table . '', 'n')
      ->extend('PagerDefault');
      ->extend('TableSort');

to turn this:

SELECT 
FROM 
taxonomy_term_data n
ORDER BY n.tid ASC

Into this:

SELECT 
FROM 
(SELECT * taxonomy_term_data LIMIT 10) n
ORDER BY n.tid ASC

I've tried passing a db_select statement into another db_select statement. I've tried query->addExpression() and db_query() to no avail.

  • 1
    Sometimes you just have to use db_query. – mradcliffe Aug 23 '16 at 22:16
1

You Can refer to this link

However you can try like below

$query->condition('<condition>', $subquery);
  • yes that will work – vishal shah Aug 24 '16 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.