1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
5 >Combining Queries</TITLE
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
10 HREF="mailto:pgsql-docs@postgresql.org"><LINK
12 TITLE="PostgreSQL 7.4.1 Documentation"
13 HREF="index.html"><LINK
16 HREF="queries.html"><LINK
19 HREF="queries-select-lists.html"><LINK
22 HREF="queries-order.html"><LINK
25 HREF="stylesheet.css"><META
27 CONTENT="2003-12-22T03:48:47"></HEAD
33 SUMMARY="Header navigation table"
43 >PostgreSQL 7.4.1 Documentation</TH
51 HREF="queries-select-lists.html"
67 >Chapter 7. Queries</TD
81 HREF="queries-order.html"
96 >7.4. Combining Queries</A
120 > The results of two queries can be combined using the set operations
121 union, intersection, and difference. The syntax is
162 > are queries that can use any of
163 the features discussed up to this point. Set operations can also
164 be nested and chained, for example
197 > effectively appends the result of
205 > (although there is no guarantee
206 that this is the order in which the rows are actually returned).
207 Furthermore, it eliminates all duplicate rows, in the sense of
220 > returns all rows that are both in the result
224 > and in the result of
228 >. Duplicate rows are eliminated
238 > returns all rows that are in the result of
242 > but not in the result of
246 >. (This is sometimes called the
250 > between two queries.) Again, duplicates
251 are eliminated unless <TT
257 > In order to calculate the union, intersection, or difference of two
258 queries, the two queries must be <SPAN
260 >"union compatible"</SPAN
262 which means that they both return the same number of columns, and
263 that the corresponding columns have compatible data types, as
265 HREF="typeconv-union-case.html"
275 SUMMARY="Footer navigation table"
286 HREF="queries-select-lists.html"
304 HREF="queries-order.html"