Beginning SQL
Beginning SQL Beginning SQL
Chapter 7 Look at the results that this query gives when executed: Location.Street MemberDetails.Street NULL Main Road NULL 45 Upper Road NULL Newish Lane NULL Newish Lane NULL Long Lane NULL Main Street NULL Long Lane NULL Main Road NULL Newish Lane NULL Long Lane Winding Road Winding Road NULL White Cliff Street NULL NULL Main Street NULL Tiny Terrace NULL If you look back at the examples of a left outer join and a right outer join, notice that a full outer join is a combination of the two. These results display all the records from the Location table and all the results from the MemberDetails table. Where there isn’t a matching record in the other table, a NULL value is returned. That completes the look at all the joins supported by SQL. The most useful is the inner join, but left outer and right outer joins have their uses as well. The next section looks at how to combine two totally separate results sets using the UNION operator. Whereas joins link the different results from each table, a UNION operator simply combines them with no particular link. Combining Results Sets with the UNION Operator 226 At times, you might want to combine the results of two quite distinct queries. There may be no link between the results of each query; you just want to display them all in one results set.
- Page 442: SELECT MAX(LastName), MIN(LastName)
- Page 446: immediately after the GROUP BY stat
- Page 450: Executing the final SQL provides th
- Page 456: Chapter 7 The INNER JOIN links the
- Page 460: Chapter 7 FilmName FirstName LastNa
- Page 464: Chapter 7 212 As mentioned, that wo
- Page 468: Chapter 7 Category Street Romance T
- Page 472: Chapter 7 216 MD1.First MD1.Last MD
- Page 476: Chapter 7 SELECT MD1.MemberId, MD1.
- Page 480: Chapter 7 220 SELECT Category, Film
- Page 484: Chapter 7 222 Location.Street Membe
- Page 488: Chapter 7 224 Category MemberId War
- Page 494: You can join the results from two o
- Page 498: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- Page 502: function and the query still works,
- Page 506: Summary Selecting Data from Differe
- Page 512: Chapter 8 A WHERE clause is added t
- Page 516: Chapter 8 238 FilmName PlotSummary
- Page 520: Chapter 8 If you think that your jo
- Page 524: Chapter 8 In the query, the Categor
- Page 528: Chapter 8 244 There is one area in
- Page 532: Chapter 8 246 SELECT FirstName, Las
- Page 536: Chapter 8 248 The subquery (SELECT
- Page 540: Chapter 8 250 Notice the use of the
Chapter 7<br />
Look at the results that this query gives when executed:<br />
Location.Street MemberDetails.Street<br />
NULL Main Road<br />
NULL 45 Upper Road<br />
NULL Newish Lane<br />
NULL Newish Lane<br />
NULL Long Lane<br />
NULL Main Street<br />
NULL Long Lane<br />
NULL Main Road<br />
NULL Newish Lane<br />
NULL Long Lane<br />
Winding Road Winding Road<br />
NULL White Cliff Street<br />
NULL NULL<br />
Main Street NULL<br />
Tiny Terrace NULL<br />
If you look back at the examples of a left outer join and a right outer join, notice that a full outer join is a<br />
combination of the two. These results display all the records from the Location table and all the results<br />
from the MemberDetails table. Where there isn’t a matching record in the other table, a NULL value is<br />
returned.<br />
That completes the look at all the joins supported by <strong>SQL</strong>. The most useful is the inner join, but left outer<br />
and right outer joins have their uses as well. The next section looks at how to combine two totally separate<br />
results sets using the UNION operator. Whereas joins link the different results from each table, a<br />
UNION operator simply combines them with no particular link.<br />
Combining Results Sets with<br />
the UNION Operator<br />
226<br />
At times, you might want to combine the results of two quite distinct queries. There may be no link<br />
between the results of each query; you just want to display them all in one results set.