0

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

1 Answers1

0

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