I had a query (part of a big query):
$query->add_where(1, '10',
db_select('users_roles', 'r')
->fields('r', array('rid'))
->where('r.uid = users_node__users_roles.uid'),
'NOT IN');
In that query there is a subquery that returns all the the rid (role id) of a specific user uid.
It will work fine if there is at least one role for a user in the role table, otherwise the subquery will return empty which will make the query:
10 NOT IN ()
How can i change the value of rid to 0 if it is empty (if the user has no roles)?
Is there any mysql case conditions to check empty of a field?
Thanks in advance. Prem