Errata

Learning SQL

Errata for Learning SQL

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Other Digital Version N/A
Chapter 5: location 2723 in the Kindle version

The query and the results do not match (the book shows results ordered by city).


QUERY IN THE BOOK:
===================

SELECT c.first_name, c.last_name, ct.city
FROM customer AS c
INNER JOIN address AS a
ON c.address_id = a.address_id
INNER JOIN city AS ct
ON a.city_id = ct.city_id;


SHOULD BE:
============

SELECT c.first_name, c.last_name, ct.city
FROM customer AS c
INNER JOIN address AS a
ON c.address_id = a.address_id
INNER JOIN city AS ct
ON a.city_id = ct.city_id
ORDER BY ct.city;

Wim Olivier  Aug 28, 2021 
Other Digital Version N/A
Chapter 5, Using the same table twice

In the Kindle version:

The following query returns 54 rows:

SELECT f.title
-> FROM film f
-> INNER JOIN film_actor fa
-> ON f.film_id = fa.film_id
-> INNER JOIN actor a
-> ON fa.actor_id = a.actor_id
-> WHERE ((a.first_name = 'CATE' AND a.last_name = 'MCQUEEN')
-> OR (a.first_name = 'CUBA' AND a.last_name = 'BIRCH'));

The text "Between them, the two actors appeared in 52 different films...",
should be "Between them, the two actors appeared in 54 different films..."

Wim Olivier  Aug 29, 2021 
Other Digital Version Chapter 4
Exercise 4-3

The table name reference for the query is wrong. The correct table name is 'payment' not 'payments'

Exercise 4-3
Construct a query that retrieves all rows from the payments table where the amount is either 1.98, 7.98, or 9.98.

Oluwatosin Ogunfile  Jan 18, 2022 
Printed, PDF, ePub, Mobi, , Other Digital Version Page Preface
Preface

The preface for this title references katakoda.com, which is no longer available to the public. The URL is no longer functional.

Can this be reworded, making it clear that you have to have an oreilly.com account
(or a free trial)?

Anonymous  Oct 05, 2022 
PDF Page Page 69
"Using the not Operator" section

I believe there is a typo in the description of the negation of the OR statement used in the example:

WHERE NOT (first_name = 'STEVEN' OR last_name = 'YOUNG')
AND create_date > '2006-01-01'

In the sentence below, "or" should be replaced by "and":
"I am retrieving only rows where the first name is not Steven or the last name is not Young whose record was created after January 1, 2006."

Anonymous  Oct 27, 2022 
Printed Page 33
Below the tip

The keyword is 'describe', and the example is 'desc'.

Josh Fry  Feb 10, 2022 
Printed Page 41
first code

HI,
I am learning SQL using the subject book. The following (page 41) does not work:
SET birth_date = str_to_date('DEC-21-1980' , '%b-%d-%y')

I am getting :
ERROR 1292 (22007): Truncated incorrect date value; 'DEC-21-198'

Can you help me?

Yossi Reichman  Aug 30, 2023 
Printed Page 49
Query and table at bottom of page

The example query at the bottom of page 49 uses aliases "language_usage", "lang_pi_value", and "language_name" without explaining that they are aliases.

I believe this is a typo and that the column aliases should not have been used in this query on page 49. Because, on page 50, the same query is repeated and it is explained you can add column labels to the result set by adding the column alias after each column in the query.

Suggested fix: Modify the query and its result set table on page 49 to remove the use of column aliases.

Anonymous  Feb 27, 2022 
Printed Page 62-63
top of page 63

The output table is wrong. The code is supposed to order first by last name, next by first name -- however in the output table, no ordering with respect ot first name is done. For example, focus on last_name that starts with M and see how first name is not ordered.

The output from the previous example was printed instead.

Anonymous  Jan 16, 2022 
PDF Page 119
Including special characters. CHAPTER 7th

Type SELECT CHAR(97,98,99,100,101,102,103); retrieves in hexadecimal form:
+---------+----------------------------------------------------------------+
| abcdefg | CHAR(97,98,99,100,101,102,103) |
+---------+----------------------------------------------------------------+
| abcdefg | 0x61626364656667 |
+---------+----------------------------------------------------------------+
Since using s\; command in line shows:
...Binary data as: Hexadecimal...

And using the MySQL documentation:
mysql> SELECT CHAR(128,129,130,131 USING utf8mb4);
+-------------------------------------+
| CHAR(128,129,130,131 USING utf8mb4) |
+-------------------------------------+
| |
+-------------------------------------+
1 row in set, 1 warning (0.01 sec)

The example in the book does not match.

Anonymous  Jan 25, 2023 
Printed Page 183
example at bottom of the page

Assuming the subquery at the bottom of page 183 returns 3, why is the result not sorted on the actor's last name, seeing that that is the third SELECTed field?

This as discussed on page 64, "Sorting via Numeric Placeholders", and as follows --I think-- from the statement "scalar subqueries may be used wherever an expression can appear" on page 182.

Anonymous  Jul 20, 2021 
Printed Page 209
first code block

Example database has no customer with zero rentals. So you cannot really test this code. When I created a customer with no rentals, the proposed null-handler still returned null since the numerator was null.

I used the following as a fix:

, count(p.amount) num_payments
, case when count(p.amount) = 0
then 0
else
round(sum(p.amount)/count(p.amount), 2)
end avg_payment


(I just put the call to ROUND() in there for practice.)

Gregory Truby  Apr 24, 2024 
Printed Page 210
Section "Handling Null Values"

I understand that this is an attempt to show the reader how to handle null values and I'm sure the code would work. However, when I tried to create a record where this safety net would kick in, I couldn't. There is a constraint in the database that prevents one from adding a record to the customer table with no address_id.

Might I suggest a tip / bird icon callout that explains that safeguarding against nulls can also be handled via constraints and cross reference the appropriate pages in Chapter 13?

Gregory Truby  Apr 24, 2024 
PDF Page 236
at the bottom

There is a typo in the second bullet point of foreign key constraints.
It should be "on delete cascade", instead of "on update cascade".

Qichun Dai  Sep 01, 2021 
Printed Page 257
1st

oreil.ly/qV7sE
Error 404--Not Found, Link is not availabe.

Sophia  Nov 06, 2022