lib/dataset/query.js
function (dataset, opts) {
            opts = isUndefined(opts) ? {} : opts;
            if (!isHash(opts)) {
                opts = {all: opts};
            }
            if (!this.supportsIntersectExcept) {
                throw new QueryError("INTERSECT not supported");
            } else if (opts.all && !this.supportsIntersectExceptAll) {
                throw new QueryError("INTERSECT ALL not supported");
            }
            return this.compoundClone("intersect", dataset, opts);
        }
function (dataset, opts) {
            opts = isUndefined(opts) ? {} : opts;
            if (!isHash(opts)) {
                opts = {all: opts};
            }
            if (!this.supportsIntersectExcept) {
                throw new QueryError("INTERSECT not supported");
            } else if (opts.all && !this.supportsIntersectExceptAll) {
                throw new QueryError("INTERSECT ALL not supported");
            }
            return this.compoundClone("intersect", dataset, opts);
        }
function ( dataset , opts ) { opts = isUndefined ( opts ) ? { } : opts ; if ( ! isHash ( opts ) ) { opts = { all : opts } ; } if ( ! this . supportsIntersectExcept ) { throw new QueryError ( "INTERSECT not supported" ) ; } else if ( opts . all && ! this . supportsIntersectExceptAll ) { throw new QueryError ( "INTERSECT ALL not supported" ) ; } return this . compoundClone ( "intersect" , dataset , opts ) ; }
Adds an INTERSECT clause using a second dataset object.
An INTERSECT compound dataset returns all rows in both the current dataset
and the given dataset.

@example

DB.from("items").intersect(DB.from("other_items")).sql;
//=> SELECT * FROM (SELECT * FROM items INTERSECT SELECT * FROM other_items) AS t1

DB.from("items").intersect(DB.from("other_items"), {all : true, fromSelf : false}).sql;
//=> SELECT * FROM items INTERSECT ALL SELECT * FROM other_items

DB.from("items").intersect(DB.from("other_items"), {alias : "i"}).sql;
//=> SELECT * FROM (SELECT * FROM items INTERSECT SELECT * FROM other_items) AS i

@throws {patio.QueryError} if the operation is not supported.
@param  {patio.Dataset} dataset the dataset to intersect
@param  {Object} [opts] options
@param {String|patio.sql.Identifier} [opts.alias] Use the given value as the {@link patio.Dataset#fromSelf} alias
@param {Boolean} [opts.all] Set to true to use INTERSECT ALL instead of INTERSECT, so duplicate rows can occur
@param {Boolean} [opts.fromSelf] Set to false to not wrap the returned dataset in a {@link patio.Dataset#fromSelf}.

@return {patio.Dataset} a cloned dataset with the INTERSECT clause.
Adds an INTERSECT clause using a second dataset object . An INTERSECT compound dataset returns all rows in both the current dataset and the given dataset .