You are previewing Sams Teach Yourself SQL in 10 Minutes, Fourth Edition.
O'Reilly logo
Sams Teach Yourself SQL in 10 Minutes, Fourth Edition

Book Description

Sams Teach Yourself SQL in 10 Minutes, Fourth Edition

New full-color code examples help you see how SQL statements are structured

Whether you're an application developer, database administrator, web application designer, mobile app developer, or Microsoft Office users, a good working knowledge of SQL is an important part of interacting with databases. And Sams Teach Yourself SQL in 10 Minutes offers the straightforward, practical answers you need to help you do your job.

Expert trainer and popular author Ben Forta teaches you just the parts of SQL you need to know–starting with simple data retrieval and quickly going on to more complex topics including the use of joins, subqueries, stored procedures, cursors, triggers, and table constraints.

You'll learn methodically, systematically, and simply–in 22 short, quick lessons that will each take only 10 minutes or less to complete.

With the Fourth Edition of this worldwide bestseller, the book has been thoroughly updated, expanded, and improved. Lessons now cover the latest versions of IBM DB2, Microsoft Access, Microsoft SQL Server, MySQL, Oracle, PostgreSQL, SQLite, MariaDB, and Apache Open Office Base. And new full-color SQL code listings help the beginner clearly see the elements and structure of the language.

10 minutes is all you need to learn how to...

  • Use the major SQL statements

  • Construct complex SQL statements using multiple clauses and operators

  • Retrieve, sort, and format database contents

  • Pinpoint the data you need using a variety of filtering techniques

  • Use aggregate functions to summarize data

  • Join two or more related tables

  • Insert, update, and delete data

  • Create and alter database tables

  • Work with views, stored procedures, and more

  • Table of Contents

    1 Understanding SQL

    2 Retrieving Data

    3 Sorting Retrieved Data

    4 Filtering Data

    5 Advanced Data Filtering

    6 Using Wildcard Filtering

    7 Creating Calculated Fields

    8 Using Data Manipulation Functions

    9 Summarizing Data

    10 Grouping Data

    11 Working with Subqueries

    12 Joining Tables

    13 Creating Advanced Joins

    14 Combining Queries

    15 Inserting Data

    16 Updating and Deleting Data

    17 Creating and Manipulating Tables

    18 Using Views

    19 Working with Stored Procedures

    20 Managing Transaction Processing

    21 Using Cursors

    22 Understanding Advanced SQL Features

    Appendix A: Sample Table Scripts

    Appendix B: Working in Popular Applications

    Appendix C : SQL Statement Syntax

    Appendix D: Using SQL Datatypes

    Appendix E: SQL Reserved Words


    Table of Contents

    1. Title Page
    2. Copyright Page
    3. Table of Contents
    4. About the Author
    5. Acknowledgments
    6. We Want to Hear from You!
    7. Reader Services
    8. Introduction
      1. Who Is the Teach Yourself SQL Book For?
      2. DBMSs Covered in This Book
      3. Conventions Used in This Book
    9. Lesson 1. Understanding SQL
      1. Database Basics
      2. What Is SQL?
      3. Try It Yourself
      4. Summary
    10. Lesson 2. Retrieving Data
      1. The SELECT Statement
      2. Retrieving Individual Columns
      3. Retrieving Multiple Columns
      4. Retrieving All Columns
      5. Retrieving Distinct Rows
      6. Limiting Results
      7. Using Comments
      8. Summary
    11. Lesson 3. Sorting Retrieved Data
      1. Sorting Data
      2. Sorting by Multiple Columns
      3. Sorting by Column Position
      4. Specifying Sort Direction
      5. Summary
    12. Lesson 4. Filtering Data
      1. Using the WHERE Clause
      2. The WHERE Clause Operators
      3. Summary
    13. Lesson 5. Advanced Data Filtering
      1. Combining WHERE Clauses
      2. Using the IN Operator
      3. Using the NOT Operator
      4. Summary
    14. Lesson 6. Using Wildcard Filtering
      1. Using the LIKE Operator
      2. Tips for Using Wildcards
      3. Summary
    15. Lesson 7. Creating Calculated Fields
      1. Understanding Calculated Fields
      2. Concatenating Fields
      3. Performing Mathematical Calculations
      4. Summary
    16. Lesson 8. Using Data Manipulation Functions
      1. Understanding Functions
      2. Using Functions
      3. Summary
    17. Lesson 9. Summarizing Data
      1. Using Aggregate Functions
      2. Aggregates on Distinct Values
      3. Combining Aggregate Functions
      4. Summary
    18. Lesson 10. Grouping Data
      1. Understanding Data Grouping
      2. Creating Groups
      3. Filtering Groups
      4. Grouping and Sorting
      5. SELECT Clause Ordering
      6. Summary
    19. Lesson 11. Working with Subqueries
      1. Understanding Subqueries
      2. Filtering by Subquery
      3. Using Subqueries as Calculated Fields
      4. Summary
    20. Lesson 12. Joining Tables
      1. Understanding Joins
      2. Creating a Join
      3. Summary
    21. Lesson 13. Creating Advanced Joins
      1. Using Table Aliases
      2. Using Different Join Types
      3. Using Joins with Aggregate Functions
      4. Using Joins and Join Conditions
      5. Summary
    22. Lesson 14. Combining Queries
      1. Understanding Combined Queries
      2. Creating Combined Queries
      3. Summary
    23. Lesson 15. Inserting Data
      1. Understanding Data Insertion
      2. Copying from One Table to Another
      3. Summary
    24. Lesson 16. Updating and Deleting Data
      1. Updating Data
      2. Deleting Data
      3. Guidelines for Updating and Deleting Data
      4. Summary
    25. Lesson 17. Creating and Manipulating Tables
      1. Creating Tables
      2. Updating Tables
      3. Deleting Tables
      4. Renaming Tables
      5. Summary
    26. Lesson 18. Using Views
      1. Understanding Views
      2. Creating Views
      3. Summary
    27. Lesson 19. Working with Stored Procedures
      1. Understanding Stored Procedures
      2. Why to Use Stored Procedures
      3. Executing Stored Procedures
      4. Creating Stored Procedures
      5. Summary
    28. Lesson 20. Managing Transaction Processing
      1. Understanding Transaction Processing
      2. Controlling Transactions
      3. Summary
    29. Lesson 21. Using Cursors
      1. Understanding Cursors
      2. Working with Cursors
      3. Summary
    30. Lesson 22. Understanding Advanced SQL Features
      1. Understanding Constraints
      2. Understanding Indexes
      3. Understanding Triggers
      4. Database Security
      5. Summary
    31. Appendix A. Sample Table Scripts
      1. Understanding the Sample Tables
      2. Obtaining the Sample Tables
    32. Appendix B. Working in Popular Applications
      1. Using Apache Open Office Base
      2. Using Adobe ColdFusion
      3. Using IBM DB2
      4. Using MariaDB
      5. Using Microsoft Access
      6. Using Microsoft ASP
      7. Using Microsoft ASP.NET
      8. Using Microsoft Query
      9. Using Microsoft SQL Server (including Microsoft SQL Server Express)
      10. Using MySQL
      11. Using Oracle
      12. Using Oracle Express
      13. Using PHP
      14. Using PostgreSQL
      15. Using SQLite
      16. Configuring ODBC Data Sources
    33. Appendix C. SQL Statement Syntax
      1. ALTER TABLE
      2. COMMIT
      3. CREATE INDEX
      4. CREATE PROCEDURE
      5. CREATE TABLE
      6. CREATE VIEW
      7. DELETE
      8. DROP
      9. INSERT
      10. INSERT SELECT
      11. ROLLBACK
      12. SELECT
      13. UPDATE
    34. Appendix D. Using SQL Datatypes
      1. String Datatypes
      2. Numeric Datatypes
      3. Date and Time Datatypes
      4. Binary Datatypes
    35. Appendix E. SQL Reserved Words
    36. Index