September 2010
Intermediate to advanced
440 pages
9h 23m
English
Sometimes, you may not want to limit results but, rather, combine results from multiple queries. Rather than execute two different SELECT statements in Python, you can pass the task to the server with UNION. A UNION is the combination of the results from two SELECT statements into a single result set. Unlike JOINs (discussed in the next section), a UNION does do not combine the results side-by-side, but one after the other. So where the results from the first query end, the results from the second query begin.
The basic syntax of a UNION is as follows:
(<SELECT statement 1>) UNION (<SELECT statement 2>);
Each SELECT statement is discrete as they are neither related nor can they rely on each other's data. The number of columns returned by each ...
Read now
Unlock full access