1

I was trying to alter a view query with a subselect that looks like:

$subquery1 = (db_select('users_roles', 'r')
   ->where('r.uid = users_node__users_roles.uid and r.rid=10'));
$subquery1->addExpression('COUNT(r.rid)', 'rid');
$query->add_where(1,'1', $subquery1, '<>');

where $query is the main query. But when i run the view, the query

...AND (1 <> SELECT COUNT(r.rid) AS rid FROM users_roles r WHERE (r.uid = users_node__users_roles.uid and r.rid=10))...

if i put brackets for the sub select query it will working fine. ie;

...AND (1 <> (SELECT COUNT(r.rid) AS rid FROM users_roles r WHERE (r.uid = users_node__users_roles.uid and r.rid=10)))...

So my question is; How can i put the subquery inside brackets? sorry if my question is stupid?

Thanks in advance, PREM

  • i found a soln; put NOT IN instead of <>. – Prem Shankar Mar 19 '14 at 6:12
0

I had found the soln myself; put NOT IN instead of <>. NOT IN will make the value part inside the brackets

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.