I tried to add a subquery like this:
function mymodule_views_query_alter(&$view) {
$view->query->where[1]['conditions'][] = array(
'field' => 'node.nid',
'value' => 'SELECT SUBSTRING(source, 6) FROM {url_alias} WHERE alias LIKE "pros/%"',
'operator' => 'in',
);
}
I have a specific case where nodes are created with aliases starting with pros/
or not, and I want to get only them.
In a simple raw SQL query, I'd go with this:
SELECT *
FROM node node
WHERE node.nid IN (SELECT SUBSTRING(source, 6)
FROM {url_alias}
WHERE alias LIKE "pros/%")
But I can't find out how to do this using hook_views_query_alter()
.