public function union($query, $overwrite = false)
    {
        if ($overwrite) {
            $this->_parts['union'] = [];
        }
        $this->_parts['union'][] = [
            'all' => false,
            'query' => $query
        ];
        $this->_dirty();

        return $this;
    }
public function union($query, $overwrite = false)
    {
        if ($overwrite) {
            $this->_parts['union'] = [];
        }
        $this->_parts['union'][] = [
            'all' => false,
            'query' => $query
        ];
        $this->_dirty();

        return $this;
    }
public function union ( $ query , $ overwrite = false ) { if ( $ overwrite ) { $ this -> _parts [ 'union' ] = [ ] ; } $ this -> _parts [ 'union' ] [ ] = [ 'all' => false , 'query' => $ query ] ; $ this -> _dirty ( ) ; return $ this ; }
Adds a complete query to be used in conjunction with an UNION operator with
this query. This is used to combine the result set of this query with the one
that will be returned by the passed query. You can add as many queries as you
required by calling multiple times this method with different queries.

By default, the UNION operator will remove duplicate rows, if you wish to include
every row for all queries, use unionAll().

### Examples

```
$union = (new Query($conn))->select(['id', 'title'])->from(['a' => 'articles']);
$query->select(['id', 'name'])->from(['d' => 'things'])->union($union);
```

Will produce:

`SELECT id, name FROM things d UNION SELECT id, title FROM articles a`

@param string|\Cake\Database\Query $query full SQL query to be used in UNION operator
@param bool $overwrite whether to reset the list of queries to be operated or not
@return $this
Adds a complete query to be used in conjunction with an UNION operator with this query . This is used to combine the result set of this query with the one that will be returned by the passed query . You can add as many queries as you required by calling multiple times this method with different queries .