A database result set is the collection of rows produced by a SELECT query. For example, selecting TitleName from the title table returns eight rows containing title names. Treat the result as the answer to a question asked of the database, rather than as a permanently ordered list. section 3.2.1
SELECT TitleName FROM title;
This query returns one column from every qualifying row in title. Without an explicit ordering instruction, the displayed row order has no guarantee. section 3.2.1
When working with result sets, remember these practical rules:
- Do not rely on row order unless the query explicitly orders its results; repeated executions can display rows differently. section 3.2.1
- Set operators can evaluate two SELECT results as one result set, but the queries must return matching column counts and compatible data types. section 10.1
- For combined results, column names and aliases come from the first SELECT, and ORDER BY belongs only after the final SELECT. section 10.1
Combining names with UNION
UNION joins the first and last names selected from customer and author into one result set, then orders that output by last name and first name. Identical rows are removed. Add a literal third column such as 'customer' or 'author' when the output must show where each row came from. section 10.2
SELECT FirstName, LastName FROM customer UNION SELECT FirstName, LastName FROM author ORDER BY LastName, FirstName;
The two SELECT statements produce compatible two-column results; UNION turns them into one ordered result set. section 10.2



