Converting a left join query with empty right side to Views
You can use this function

function MY_MODULE_views_query_alter(&amp;$view, &amp;$query) {
    if($view-&gt;name == 'view_name'){
       }
}


https://api.drupal.org/api/views/views.api.php/function/hook_views_query_alter/7