Provide two different queries for search field depending on search condition

[size=4]Hello. I have a list with tags. I need to show for user companies that contain tag or companies that don’t have tags at all, how can i do this.

I think i have to use different queries, is it possible ?[/size]

Hi Sergey,

Does select the blank spaces that currently highlighted not work?

Are you using the list view filter? If so what module?

It is a custom module, blank means get all records.

can i use function to provide SQL query as string, for example ?

$searchFields['Accounts'] = [
 'related_tags' => [
    'db_field' => ['id'],
    'operator' => 'subquery',
    'query_type' => 'format',
    'function' => ['name' => 'composeQuery'],

function composeQuery($searchTag){
  return 'query here';

If so where should i place composeQuery function ?