function SelectInterface::union

Same name in other branches
  1. 9 core/lib/Drupal/Core/Database/Query/SelectInterface.php \Drupal\Core\Database\Query\SelectInterface::union()
  2. 8.9.x core/lib/Drupal/Core/Database/Query/SelectInterface.php \Drupal\Core\Database\Query\SelectInterface::union()
  3. 10 core/lib/Drupal/Core/Database/Query/SelectInterface.php \Drupal\Core\Database\Query\SelectInterface::union()

Add another Select query to UNION to this one.

Union queries consist of two or more queries whose results are effectively concatenated together. Queries will be UNIONed in the order they are specified, with this object's query coming first. Duplicate columns will be discarded. All forms of UNION are supported, using the second '$type' argument.

Note: All queries UNIONed together must have the same field structure, in the same order. It is up to the caller to ensure that they match properly. If they do not, an SQL syntax error will result.

Parameters

$query: The query to UNION to this query.

$type: The type of UNION to add to the query. Defaults to plain UNION.

Return value

$this The called object.

2 methods override SelectInterface::union()
Select::union in core/lib/Drupal/Core/Database/Query/Select.php
Add another Select query to UNION to this one.
SelectExtender::union in core/lib/Drupal/Core/Database/Query/SelectExtender.php
Add another Select query to UNION to this one.

File

core/lib/Drupal/Core/Database/Query/SelectInterface.php, line 458

Class

SelectInterface
Interface definition for a Select Query object.

Namespace

Drupal\Core\Database\Query

Code

public function union(SelectInterface $query, $type = '');

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.