John L. Viescas, Michael J. Hernandez0321444434, 9780321444431
Table of contents :
SQL Queries for Mere Mortals, 2nd Edition……Page 1
Contents……Page 8
Foreword……Page 18
Preface……Page 20
About the Authors……Page 22
Are You a Mere Mortal?……Page 24
About This Book……Page 25
What This Book Is Not……Page 26
How to Use This Book……Page 27
Reading the Diagrams Used in This Book……Page 28
Sample Databases Used in This Book……Page 31
“Follow the Yellow Brick Road”……Page 33
PART I: Relational Databases and SQL……Page 36
Types of Databases……Page 38
A Brief History of the Relational Model……Page 39
Anatomy of a Relational Database……Page 41
What’s in It for You?……Page 50
Where Do You Go from Here?……Page 51
Summary……Page 52
Why Is This Chapter Here?……Page 54
Why Worry about Sound Structures?……Page 55
Fine-Tuning Fields……Page 56
Fine-Tuning Tables……Page 65
Establishing Solid Relationships……Page 77
Is That All?……Page 85
Summary……Page 86
Topics Covered in This Chapter……Page 88
The Origins of SQL……Page 89
Early Vendor Implementations……Page 90
“. . . And Then There Was a Standard”……Page 91
Evolution of the ANSI/ISO Standard……Page 93
Commercial Implementations……Page 99
Why Should You Learn SQL?……Page 100
Summary……Page 101
PART II: SQL Basics……Page 104
Topics Covered in This Chapter……Page 106
Introducing SELECT……Page 107
The SELECT Statement……Page 108
A Quick Aside: Data versus Information……Page 110
Translating Your Request into SQL……Page 112
Eliminating Duplicate Rows……Page 119
Sorting Information……Page 122
Saving Your Work……Page 127
Sample Statements……Page 128
Summary……Page 137
Problems for You to Solve……Page 138
Topics Covered in This Chapter……Page 140
What Is an Expression?……Page 141
What Type of Data Are You Trying to Express?……Page 142
Changing Data Types: The CAST Function……Page 145
Specifying Explicit Values……Page 147
Types of Expressions……Page 152
Using Expressions in a SELECT Clause……Page 163
That “Nothing” Value: Null……Page 170
Sample Statements……Page 174
Summary……Page 182
Problems for You to Solve……Page 184
Refining What You See Using WHERE……Page 186
Defining Search Conditions……Page 191
Using Multiple Conditions……Page 213
Nulls Revisited: A Cautionary Note……Page 228
Expressing Conditions in Different Ways……Page 232
Sample Statements……Page 233
Summary……Page 241
Problems for You to Solve……Page 242
PART III: Working with Multiple Tables……Page 246
Topics Covered in This Chapter……Page 248
What Is a Set, Anyway?……Page 249
Operations on Sets……Page 250
Intersection……Page 251
Difference……Page 257
Union……Page 263
SQL Set Operations……Page 268
Summary……Page 277
What Is a JOIN?……Page 278
The INNER JOIN……Page 279
Uses for INNER JOINs……Page 297
Sample Statements……Page 298
Summary……Page 323
Problems for You to Solve……Page 324
What Is an OUTER JOIN?……Page 328
The LEFT/RIGHT OUTER JOIN……Page 330
The FULL OUTER JOIN……Page 349
Uses for OUTER JOINs……Page 353
Sample Statements……Page 354
Problems for You to Solve……Page 370
What Is a UNION?……Page 374
Writing Requests with UNION……Page 377
Uses for UNION……Page 387
Sample Statements……Page 388
Summary……Page 400
Problems for You to Solve……Page 401
Topics Covered in This Chapter……Page 404
What Is a Subquery?……Page 405
Subqueries as Column Expressions……Page 407
Subqueries as Filters……Page 412
Uses for Subqueries……Page 427
Sample Statements……Page 429
Summary……Page 444
Problems for You to Solve……Page 445
PART IV: Summarizing and Grouping Data……Page 448
Topics Covered in This Chapter……Page 450
Aggregate Functions……Page 451
Using Aggregate Functions in Filters……Page 463
Sample Statements……Page 466
Summary……Page 473
Problems for You to Solve……Page 474
Topics Covered in This Chapter……Page 476
Why Group Data?……Page 477
The GROUP BY Clause……Page 479
“Some Restrictions Apply”……Page 489
Uses for GROUP BY……Page 493
Sample Statements……Page 494
Summary……Page 505
Problems for You to Solve……Page 506
Topics Covered in This Chapter……Page 508
A New Meaning of “Focus Groups”……Page 509
When You Filter Makes a Difference……Page 513
Uses for HAVING……Page 521
Sample Statements……Page 522
Problems for You to Solve……Page 531
PART V: Modifying Sets of Data……Page 534
What Is an UPDATE?……Page 536
The UPDATE Statement……Page 537
Uses for UPDATE……Page 551
Sample Statements……Page 552
Summary……Page 568
Problems for You to Solve……Page 569
What Is an INSERT?……Page 572
The INSERT Statement……Page 574
Uses for INSERT……Page 585
Sample Statements……Page 587
Summary……Page 597
Problems for You to Solve……Page 598
What Is a DELETE?……Page 602
The DELETE Statement……Page 603
Uses for DELETE……Page 610
Sample Statements……Page 611
Summary……Page 618
Problems for You to Solve……Page 619
In Closing……Page 622
APPENDICES……Page 624
A: SQL Standard Diagrams……Page 626
B: Schema for the Sample Databases……Page 636
C: Date and Time Functions……Page 642
D: Suggested Reading……Page 650
B……Page 652
C……Page 653
D……Page 654
E……Page 655
G……Page 656
I……Page 657
M……Page 658
N……Page 659
P……Page 660
R……Page 661
S……Page 662
T……Page 664
U……Page 665
X……Page 666
Reviews
There are no reviews yet.