Hook subquery problem

Hello

I want write the SQL with MyModuleviews_query_alter

I have 2 content types :

Post Type Post

Name Title
Entity reference Post Type

I want show all Post Type which have one or more post

if($view->name == ‘spaces_checking’ ) {

foreach ($query->where as &$condition_group) {
foreach ($condition_group[‘conditions’] as &$condition) {

if ($condition[‘field’] == ‘node.title’) {
$condition = array(
‘field’ => ‘node.nid’,
‘value’ => ‘SELECT SUBSTRING(source, 6) FROM {Post} ‘,
‘operator’ => ‘in’,
);
}
}

}
}


Source: https://www.drupal.org/taxonomy/term/2/feed