Book description
What will you learn from this book?
Do you have an abundance of data but don't know how to make sense of it? Do you want to gain useful insights from your data, but you're not sure where to begin? Mining data is a vital, well-paying skill, and SQL provides the most fundamental way to query and manage data. But learning SQL can be intimidating. This thoroughly revised book teaches you SQL fundamentals in a painless and enjoyable manner. With the Head First series' hands-on, conversational style, you'll quickly grasp SQL concepts, then move to intermediate topics, including stored procedures and cloud databases. You'll gain the knowledge, skills, and confidence necessary to get the most out of your data with SQL.
Why does this book look so different?
If you've read a Head First book, you know what to expect: a visually rich format designed for the way your brain works. If you haven't, you're in for a treat. With this book, you'll learn about SQL through a multisensory experience that engages your mind—rather than a text-heavy approach that puts you to sleep.
Publisher resources
Table of contents
- Brief Table of Contents (Not Yet Final)
-
1. Databases and Tables: Organizing Your Information
- Defining your data
- Think about your data in categories
- Build a table of information
- What is SQL?
- The anatomy of a table
- A table of travel data
- BE the table
- BE the table Solution
- What’s a database?
- Databases contain related information
- Take command!
- Your first SQL commands
- Creating a SQL table
- Steps for creating a general SQL table
- Your table is ready
- A selection of common data types
- Who am I?
- Your table, DESCribed
- Changing table properties
- Code Magnets
- Code Magnets Solution
- Dropping and recreating tables
- Adding a new column
- Hitting your cruising altitude
- SQLcross
- Your SQL toolbox
- Who am I? Solution
- SQLcross Solution
-
2. Inserting Data: Adding Table Rows
- Setting up a database with tables
- Checking back in with Abby
- Inserting data into tables
- Creating your INSERT statement
- See your table with SELECT
- A new recommendation
- Records with missing values
- Revisiting your table
- Controlling NULLs...
- ... and Setting DEFAULTs
- Variations on INSERT #1
- Variations on INSERT #2
- Variations on INSERT #3
- A punctuation problem
- Unmatched single quotes
- INSERT data with single quotes in it
- It’s only up from here!
- SQLcross
- Your SQL toolbox
- SQLcross Solution
-
3. The Select Statement: Finding Your Information
- Searching for a destination
- SELECT specific columns
- Specify columns... and their order
- An even better SELECT
- WHERE to next?
- WHERE filters out rows
- WHERE results
- Finding numeric values
- Expanding a numeric search
- Short travel times using less than
- Comparison Operators
- Finding numeric data with comparison operators
- Comparison operators for text
- Who am I?
- Who am I? Solution
- SQLcross
- Your SQL Toolbox
- SQLcross Solution
-
4. Better Where Clauses Filtering Rows
- Misplaced identification
- Multiple row requirements
- Combining your queries
- Use AND to satisfy two conditions
- To be OR not to be
- Code Magnets
- Code Magnets Solution
- Fireside Chats
- The difference between AND and OR
- BE the Conditional
- Be the Conditional Solution
- Use IS NULL to find NULLs
- IS NULL in your console
- Selecting ranges using AND and comparison operators
- Just BETWEEN us... there’s a better way
- Meanwhile, Abby dreams of sunshine...
- Save time with LIKE
- I’d LIKE to buy a wildcard, please
- You’re either IN...
- ... or you are NOT IN
- And that’s NOT all
- WHERE for the win
- SQLcross
- Your SQL toolbox
- SQLcross Solution
-
5. CRUD Operations Controlling Your Data
- What’s for dinner?
- Extracting information
- Getting to know CRUD
- Cubicle conversation
- Change your data with UPDATE
- Staying up-to-date with UPDATE
- UPDATE in your console
- Updating multiple columns or rows
- The price is wrong
- Revisiting CRUD
- Getting rid of rows with DELETE
- DELETE rules
- DELETE (+SELECT) in your console
- CRUD complete
- SQLcross
- Your SQL toolbox
- SQLcross Solution
-
6. Advanced Select Sorting and Aggregating
- Shopping around
- ORDER (BY) in the court!
- ORDER with WHERE
- An orderly stores table
- Reverse the ORDER with DESC
- LIMIT the number of results
- Hitting the LIMIT
- SUM to add values for us
- SUM all of them at once with GROUP BY
- Imagine GROUP BY splitting your data
- Getting group averages
- MIN and MAX
- The COUNT of Monty Bristow
- SELECT DISTINCT values
- Filtering groups
- HAVING the right filter mechanism
- Easy as S.F.W.G.H.O.
- Your very own categorization
- A CASE for new groups
- SELECTing a CASE expression
- Go with the CASE flow
- Alias your columns with AS
- Even more power with aliasing
- An impressive list of abilities
- SQLcross
- Your SQL toolbox
- SQLcross Solution
-
7. Normalization and Multiple Tables Thoughtful Table Design
- Two mountainous tables
- A table is all about relationships
- Atomic data
- Asking atomic questions
- More atomic updates
- Get into a normal routine
- What’s normal and 1NF?
- PRIMARY KEY to success
- Getting to normal
- The CREATE TABLE with a PRIMARY KEY
- 1, 2, 3... automatically
- Adding a PRIMARY KEY to an existing table
- ALTER TABLE to add a PRIMARY KEY
- Think outside of the single table
- Abby’s database schema
- Going from one table to two
- Querying two tables
- Connecting your tables
- FOREIGN KEY to success
- Constraining your foreign key
- CREATE a table with a FOREIGN KEY
- One-to-one
- One-to-many
- Many-to-many
- We need a junction table
- Fixing data patterns
- How normal can you be?
- Composite keys use multiple columns
- Partial functional dependency
- Transitive functional dependency
- Second Normal Form (2NF)
- Third Normal Form (3NF)
- Your SQL toolbox
-
8. Alter Changing and Optimizing
- Summer camp chaos
- Ready for renovations
- Table altering
- Renaming our table
- Making a CHANGE
- Choosing your data types
- Storage considerations for text
- MODIFY a data type
- Slowing to a crawl
- INDEX for faster queries
- Two ways to INDEX
- Composite index ordering
- ALTER your awkward columns
- A few handy string functions
- UPDATE with string functions
- Create data-filled tables
- Your SQL toolbox
-
9. Joins and Unions: Multiple-table Operations
- Time to JOIN the party
- The CROSS JOIN
- Filtering a CROSS JOIN
- Releasing your INNER JOIN
- The inner join in action
- Other ON conditions
- OUTER this world!
- The left join in action
- Flipping your table order
- Outer joins and multiple matches
- Right (outer) join
- FULL OUTER JOIN
- A self-referencing foreign key
- Joining a table to itself
- We’re ready for a self join
- Another way to combine multiple tables
- You can use a UNION
- UNION rules in action
- UNION ALL
- JOINing the fun at Camp Calloway
- Your SQL toolbox
-
10. Subqueries: Queries within Queries
- Low-budget options
- Two-step troubles
- Subqueries
- Combine the inner and outer queries
- A subquery as a SELECT column
- Subquery construction walk through
- Subqueries with multiple results
- Non-correlated subqueries
- Correlated subqueries
- A correlated subquery with NOT EXISTS...
- Click bait?
- Turning a subquery into a join
- FROM subqueries
- Common table expressions (CTEs)
- Derived tables vs. CTEs
- Subquery success
- Your SQL toolbox
- About the Author
Product information
- Title: Head First SQL, 2nd Edition
- Author(s):
- Release date: August 2026
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781098163655
You might also like
book
Head First SQL
Is your data dragging you down? Are your tables all tangled up? Well we've got the …
book
Learning SQL, 3rd Edition
As data floods into your company, you need to put it to work right away—and SQL …
video
Learning SQL
Almost 3 Hours of Video Instruction Your complete SQL video course: Master hands-on, real-world skills for …
book
Practical SQL, 2nd Edition
Practical SQL is an approachable and fast-paced guide to SQL (Structured Query Language), the standard programming …