Copyright
Table of Contents
Foreword
Preface
How to Use This Book
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
Chapter 1. Why Learn SQL?
What Is SQL and Why Is It Marketable?
Who Is SQL For?
Chapter 2. Databases
What Is a Database?
Exploring Relational Databases
Why Separate Tables?
Choosing a Database Solution
Chapter 3. SQLite
What Is SQLite?
SQLiteStudio
Importing and Navigating Databases
Chapter 4. SELECT
Retrieving Data with SQL
Expressions in SELECT Statements
Text Concatenation
Summary
Chapter 5. WHERE
Filtering Records
Using WHERE on Numbers
AND, OR, and IN Statements
Using WHERE on Text
Using WHERE on Booleans
Handling NULL
Grouping Conditions
Summary
Chapter 6. GROUP BY and ORDER BY
Grouping Records
Ordering Records
Aggregate Functions
The HAVING Statement
Getting Distinct Records
Summary
Chapter 7. CASE Statements
The CASE Statement
Grouping CASE Statements
The “Zero/Null” CASE Trick
Summary
Chapter 8. JOIN
Stitching Tables Together
INNER JOIN
LEFT JOIN
Other JOIN Types
Joining Multiple Tables
Grouping JOINs
Summary
Chapter 9. Database Design
Planning a Database
The SurgeTech Conference
ATTENDEE
COMPANY
PRESENTATION
ROOM
PRESENTATION_ATTENDANCE
Primary and Foreign Keys
The Schema
Creating a New Database
CREATE TABLE
Setting the Foreign Keys
Creating Views
Summary
Chapter 10. Managing Data
INSERT
Multiple INSERTs
Testing the Foreign Keys
DELETE
TRUNCATE TABLE
UPDATE
DROP TABLE
Summary
Chapter 11. Going Forward
Appendix A. Operators and Functions
Appendix A1 – Literal Expression Queries
Appendix A2 – Mathematical Operators
Appendix A3 – Comparison Operators
APPENDIX A4 – Logical Operators
APPENDIX A5 – Text Operators
APPENDIX A6 – Common Core Functions
APPENDIX A7 – Aggregate Functions
APPENDIX A8 – Date and Time Functions
Date Functions
Time Functions
Date/Time Functions
Appendix B. Supplementary Topics
APPENDIX B1 – Further Topics of Interest
APPENDIX B2 – Improving Performance with Indexes
Appendix B3 – Transactions
Index
About the Author