SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL (Paperback)
暫譯: SQL 查詢入門:SQL 數據操作實用指南 (平裝本)

Michael J. Hernandez, John L. Viescas

  • 出版商: Addison Wesley
  • 出版日期: 2000-08-31
  • 定價: $1,980
  • 售價: 5.0$990
  • 語言: 英文
  • 頁數: 528
  • 裝訂: Paperback
  • ISBN: 0201433362
  • ISBN-13: 9780201433364
  • 相關分類: SQL
  • 立即出貨(限量) (庫存=8)

買這商品的人也買了...

相關主題

商品描述


Description

The practical, hands-on, plain-English guide to getting results with SQL!

  • No unnecessary jargon: just real help and useful examples!
  • Covers every SQL skill business database users need most: drawing data from multiple tables, grouping, totaling, summaries, and much more.
  • CD-ROM contains five real-world sample databases for use with the book's example queries.
Now there's a practical, hands-on guide to SQL for millions of beginning-to-intermediate database users who desperately need to create fast, accurate, effective queries -- whether they have formal database training or not. The authors begin by introducing the fundamental concepts underlying relational databases and SQL. They then introduce the absolute basics of SQL, including the SELECT statement, creating expressions, and applying filters. Next, they introduce techniques for solving one of the most common problems database users encounter: drawing data from multiple tables at once. The book includes detailed coverage of grouping, totaling, and summarizing data; using SQL to update, insert, and delete data; and more. In the final section, Hernandez and Viescas introduce "thinking out of the box" techniques that allow users to solve a wide variety of complex SQL problems. Most chapters end with sample problems, solutions, and result sets -- all based on a library of five real-world databases included on the accompanying CD-ROM.

Michael J. Hernandez is a well-known relational database consultant, top-rated Microsoft Access instructor, and owner of DataTex Consulting Group in Seattle, WA. He is author of the best-selling Database Design for Mere Mortals, 0-201-69471-9. John L. Viescas is President of Viescas Consulting, Inc., a respected provider of database consulting services. He is the author of Running Microsoft Access 97 and Quick Reference Guide to SQL, which has been hailed as "the Strunk and White of SQL."

Back to Top


Table Of Contents

Foreword.
Preface and Acknowledgments.
About the Authors.
Introduction.
Are You a Mere Mortal?
About This Book.
How to Use This Book.
Reading the Diagrams Used in This Book.
Sample Databases Used in This Book.
"Follow the Yellow Brick Road".

I. RELATIONAL DATABASES AND SQL.


1. What Is "Relational?"
Topics Covered in This Chapter.
Types of Databases.
A Brief History of the Relational Model.
In the Beginning . . ..
Relational Database Software.

Anatomy of a Relational Database.
Tables.
Fields.
Records.
Keys.
Views.
Relationships.

What's in It for Me?
"Where Do I Go from Here?"


2. Ensuring Your Database Structure Is Sound.
Topics Covered in This Chapter.
Why Is This Chapter Here?
Why Worry about Sound Structures?
Fine-tuning Fields.
What's in a Name? (Part One).
Smoothing Out the Rough Edges.
Resolving Multipart Fields.
Resolving Multivalued Fields.

Fine-tuning Tables.
What's in a Name? (Part Two).
Ensuring a Sound Structure.
Resolving Unnecessary Duplicate Fields.
Identification Is the Key.

Establishing Solid Relationships.
Establishing a Deletion Rule.
Setting the TYpe of Participation.
Setting the Degree of Participation.

Is That All?

3. A Concise History of SQL.
Topics Covered in This Chapter.
The Origins of SQL.
Early Vendor Implementation.
". . . And Then There Was a Standard".
Evolution of the ANSI/ISO Standard.
Other SQL Standards.
Commercial Implementations.

What the Future Holds.
Why Should You Learn SQL?

II. SQL BASICS.


4. Creating a Simple Query.
Topics Covered in This Chapter.
Introducing SELECT.
The SELECT Statement.
Major Clauses in a SELECT Statement.

A Quick Aside: Data vs. Information.
Translating Your Request into SQL.
Expanding the Field of Vision.

Eliminating Duplicate Rows.
Sorting Information.
First Things First: Collating Sequences.
Let's Now Come to Order.

Saving Your Work.
Sample Statements.
Problems for You to Solve.

5. Getting More Than Simple Columns.
Topics Covered in This Chapter.
The SELECT Clause: Take Two.
Specifying Explicit Values.

Moving Beyond Basic Information.
What Is an Expression?
What Are You Trying to Express?
Data Types in SQL.

Types of Expressions.
Concatenation.
Mathematical.
Date And Time Arithmetic.

Using Expressions in a SELECT Clause.
A Brief Digression: Value Expressions.

That "Nothing" Value--NULL.
Introducing Null.

Sample Statements.
Problems for You to Solve.

6. Filtering Your Data.
Topics Covered in This Chapter.
Refining What You See Using WHERE.
The WHERE Clause.
Using A WHERE Clause.

Defining Search Conditions.
Comparison.
Range.
Set Membership.
Pattern Match.
Null.
Excluding Rows with NOT.

Using Multiple Conditions.
Introducing AND and OR.
Excluding Rows: Take Two.
Order of Precedence.

Nulls Revisited: A Cautionary Note.
Expressing Conditions in Different Ways.
Sample Statements.
Problems for You to Solve.

III. WORKING WITH MULTIPLE TABLES.


7. Thinking in Sets.
Topics Covered in This Chapter.
What Is a Set, Anyway?
Operations on Sets.
Intersection.
Intersection in Set Theory.
Intersection between Result Sets.
Problems You Can Solve with INTERSECT.

Difference.
Difference in Set Theory.
Difference Between Result Sets.
Problems You Can Solve with DIFFERENCE.

Union.
Union in Set Theory.
Combining Result Sets Using UNION.
Problems You Can Solve with UNION.

SQL Set Operations.
"Classical" Set Operations vs. SQL.
Finding Common Values--INTERSECT.
Finding Missing Values--EXCEPT (Difference).
Combining Sets--UNION.


8. INNER JOINs.
Topics Covered in This Chapter.
What Is a JOIN?
The INNER JOIN.
What's "Legal" to JOIN?
Syntax.
Check Those Relationships!

Uses for INNER JOINs.
Find Related Rows.
Find Matching Values.

Sample Statements.
Two Tables.
More Than Two Tables.
Looking for Matching Values.

Problems for You to Solve.

9. OUTER JOINs.
Topics Covered in This Chapter.
What is an OUTER JOIN?
The Left/Right OUTER JOIN.
Syntax.

The FULL OUTER JOIN.
Syntax.
FULL OUTER JOIN on Non-Key Values.
UNION JOIN.

Uses for OUTER JOINS.
Find Missing Values.
Find Partially Matched Information.

Sample Statements.
Problems for You to Solve.

10. UNIONs.
Topics Covered in This Chapter.
What Is a Union?
Writing Requests with UNION.
Using Simple SELECT Statements.
Combining Complex SELECT Statements.
Using UNION More Than Once.
Sorting a UNION.

Uses for UNION.
Sample Statements.
Problems for You to Solve.

11. Subqueries.
Topics Covered in This Chapter.
What Is a Subquery?
Row Subqueries.
Table Subqueries.
Scalar Subqueries.

Subqueries as Column Expressions.
Syntax.
An Introduction to Aggregate Functions--COUNT and MAX.

Subqueries as Filters.
Syntax.
Special Predicate Keywords for Subqueries.

Uses for Subqueries.
Column Expressions.
Filters.

Sample Statements.
Subqueries in Expressions.
Subqueries in Filters.

Problems for You to Solve.

IV. SUMMARIZING AND GROUPING DATA.


12. Summarizing Data.
Topics Covered in This Chapter.
Aggregate functions.
Counting Rows and Values with COUNT.
Computing a Total with SUM.
Calculating a Mean Value with AVG.
Finding the Largest Value with MAX.
Finding the Smallest Value with MIN.
Using More Than One Function.

Using Aggregate Functions in Filters.
Sample Statements.
Problems for You to Solve.

13. Grouping Data.
Topics Covered in This Chapter.
Why Group Data?
The GROUP BY Clause.
Syntax.
Mixing Columns and Expressions.
Using GROUP BY in a Subquery in a WHERE Clause.
Simulating a SELECT DISTINCT Statement.

"Some Restrictions Apply".
Column Restrictions.
Grouping on Expressions.
Uses for GROUP BY.

Sample Statements.
Problems for You to Solve.

14. Filtering Grouped Data.
Topics Covered in This Chapter.
A New Meaning of "Focus Groups".
When You Filter Makes A Difference.
Should You Filter in WHERE or in HAVING?
Avoiding the HAVING COUNT Trap.

Uses for HAVING.
Sample Statements.
Problems for You to Solve.

In Closing.

APPENDICES.

A. SQL Standard Diagrams.
B. Schema for the Sample Databases.
C. Recommended Reading References.
Index. 0201433362T04062001


Back to Top

商品描述(中文翻譯)

```

描述


實用、動手操作的簡明指南,幫助您使用 SQL 獲得結果!


  • 無不必要的行話:只有真正的幫助和有用的範例!

  • 涵蓋商業資料庫使用者最需要的每一項 SQL 技能:從多個表中提取資料、分組、總計、摘要等等。

  • CD-ROM 包含五個真實世界的範例資料庫,可用於書中的範例查詢。

現在有一本實用的、動手操作的 SQL 指南,適合數百萬名初學到中級的資料庫使用者,他們迫切需要創建快速、準確、有效的查詢——無論他們是否接受過正式的資料庫訓練。作者首先介紹了關聯資料庫和 SQL 的基本概念。接著,他們介紹了 SQL 的絕對基礎,包括 SELECT 語句、創建表達式和應用過濾器。然後,他們介紹了解決資料庫使用者最常遇到的問題之一的技術:一次從多個表中提取資料。本書詳細涵蓋了分組、總計和摘要資料的內容;使用 SQL 更新、插入和刪除資料;等等。在最後一部分,Hernandez 和 Viescas 介紹了「跳出框框思考」的技術,讓使用者能夠解決各種複雜的 SQL 問題。大多數章節以範例問題、解決方案和結果集結尾——所有內容均基於隨附 CD-ROM 中的五個真實世界資料庫。

Michael J. Hernandez 是知名的關聯資料庫顧問、評價最高的 Microsoft Access 講師,以及位於華盛頓州西雅圖的 DataTex Consulting Group 的擁有者。他是暢銷書 Database Design for Mere Mortals 的作者,ISBN 0-201-69471-9。John L. Viescas 是 Viescas Consulting, Inc. 的總裁,該公司是受人尊敬的資料庫顧問服務提供商。他是 Running Microsoft Access 97Quick Reference Guide to SQL 的作者,後者被譽為「SQL 的 Strunk and White」。

回到頂部


目錄


前言。
序言與致謝。
關於作者。
介紹。
您是普通人嗎?
本書介紹。
如何使用本書。
閱讀本書中使用的圖表。
本書中使用的範例資料庫。
'跟隨黃磚路'。

I. 關聯資料庫與 SQL。





1. 什麼是「關聯」?
本章涵蓋的主題。
資料庫類型。
關聯模型的簡史。
在開始之前……
關聯資料庫軟體。



關聯資料庫的結構。
表格。
欄位。
記錄。
鍵。
視圖。
關係。



這對我有什麼好處?
'我該從這裡去哪裡?'





2. 確保您的資料庫結構是健全的。
本章涵蓋的主題。
為什麼這一章在這裡?
為什麼要擔心健全的結構?
微調欄位。
名字的意義?(第一部分)。
平滑粗糙邊緣。
解決多部分欄位。
解決多值欄位。



微調表格。
名字的意義?(第二部分)。
確保結構健全。
解決不必要的重複欄位。
識別是關鍵。



建立穩固的關係。
建立刪除規則。
設定參與類型。
設定參與程度。



這樣就結束了嗎?


3. SQL 的簡明歷史。
本章涵蓋的主題。
SQL 的起源。
早期供應商實現。
'……然後就有了標準'。
ANSI/ISO 標準的演變。
其他 SQL 標準。
商業實現。



未來的展望。
為什麼您應該學習 SQL?

II. SQL 基礎。





4. 創建簡單查詢。
本章涵蓋的主題。
介紹 SELECT。
SELECT 語句。
SELECT 語句中的主要子句。



簡短的旁白:資料與資訊。
將您的請求轉換為 SQL。
擴大視野。



消除重複行。
排序資訊。
首先:排序序列。
現在讓我們來整理。



保存您的工作。
範例語句。
您需要解決的問題。


5. 獲取不僅僅是簡單的欄位。
本章涵蓋的主題。
SELECT 子句:第二次。
指定明確的值。



超越基本資訊。
什麼是表達式?
您想表達什麼?
SQL 中的資料類型。



表達式的類型。
串接。
數學。
日期和時間運算。



在 SELECT 子句中使用表達式。
簡短的插曲:值表達式。



那個「無」值——NULL。
介紹 Null。



範例語句。
您需要解決的問題。


6. 過濾您的資料。
本章涵蓋的主題。
使用 WHERE 精煉您所見的內容。
WHERE 子句。
使用 WHERE 子句。



定義搜尋條件。
比較。
範圍。
集合成員資格。
模式匹配。
Null。
使用 NOT 排除行。



使用多個條件。
介紹 AND 和 OR。
排除行:第二次。
優先順序。



Null 再次回顧:警示說明。
以不同方式表達條件。
範例語句。
您需要解決的問題。

III. 使用多個表。





7. 集合思維。
本章涵蓋的主題。
集合到底是什麼?
集合運算。
交集。
集合論中的交集。
結果集之間的交集。
您可以用 INTERSECT 解決的問題。



差異。
集合論中的差異。
結果集之間的差異。
您可以用 DIFFERENCE 解決的問題。



聯集。
集合論中的聯集。
使用 UNION 結合結果集。
您可以用 UNION 解決的問題。



SQL 集合運算。
'經典' 集合運算與 SQL。
尋找共同值——INTERSECT。
尋找缺失值——EXCEPT(差異)。
結合集合——UNION。





8. INNER JOIN。
本章涵蓋的主題。
JOIN 是什麼?
INNER JOIN。
什麼是「合法」的 JOIN?
語法。
檢查那些關係!



INNER JOIN 的用途。
查找相關行。
查找匹配值。



範例語句。
兩個表。
超過兩個表。
尋找匹配值。



您需要解決的問題。


9. OUTER JOIN。
本章涵蓋的主題。
OUTER JOIN 是什麼?
左/右 OUTER JOIN。
語法。



FULL OUTER JOIN。
語法。
在非鍵值上進行 FULL OUTER JOIN。
UNION JOIN。



OUTER JOIN 的用途。
查找缺失值。
查找部分匹配的資訊。



範例語句。
您需要解決的問題。


10. UNION。
本章涵蓋的主題。
聯集是什麼?
使用 UNION 撰寫請求。
使用簡單的 SELECT 語句。
結合複雜的 SELECT 語句。
多次使用 UNION。
對 UNION 進行排序。



UNION 的用途。
範例語句。
您需要解決的問題。


11. 子查詢。
本章涵蓋的主題。
子查詢是什麼?
行子查詢。
表子查詢。
標量子查詢。



子查詢作為欄位表達式。
語法。
聚合函數的介紹——COUNT 和 MAX。



子查詢作為過濾器。
語法。
子查詢的特殊謂詞關鍵字。



子查詢的用途。
欄位表達式。
過濾器。



範例語句。
表達式中的子查詢。
過濾器中的子查詢。



您需要解決的問題。

IV. 總結與分組資料。





12. 總結資料。
本章涵蓋的主題。
聚合函數。
使用 COUNT 計算行和值。
使用 SUM 計算總和。
使用 AVG 計算平均值。
使用 MAX 找到最大值。
使用 MIN 找到最小值。
使用多個函數。



在過濾器中使用聚合函數。
範例語句。
您需要解決的問題。


13. 分組資料。
本章涵蓋的主題。
為什麼要分組資料?
GROUP BY 子句。
語法。
混合欄位和表達式。
在 WHERE 子句中的子查詢中使用 GROUP BY。
模擬 SELECT DISTINCT 語句。



'某些限制適用'。
欄位限制。
在表達式上分組。
GROUP BY 的用途。



範例語句。
您需要解決的問題。


14. 過濾分組資料。
本章涵蓋的主題。
'焦點小組' 的新意義。
過濾的時機很重要。
您應該在 WHERE 還是 HAVING 中過濾?
避免 HAVING COUNT 陷阱。



HAVING 的用途。
```