$query1 = \Drupal::database()->select('node', 'n');
$query1->condition('n.type', 'page');
$query1->addField('n', 'nid');
$query2 = \Drupal::database()->select('node', 'n');
$query2->condition('n.type', 'article');
$query2->addField('n', 'nid');
$query = \Drupal::database()->select($query1->union($query2), 'n');
$results = $query->execute();
Add new comment