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
Printed Page 14
Learning SQL

When I download the sample from the book, and load the data from
the sample, I get a 1064 error.

Anonymous   
Printed Page 18
Tip, Suggestion, or General Note

"Oracle Database allows. . . for varchar columns."
should be
"Oracle Database allows. . . for varchar2 columns."

Anonymous   
Printed Page 19
3rd paragraph

... "unsigned" ... greater than zero
should be:
... "unsigned" ... greater than or equal to zero

Anonymous   
Printed Page 19
Table 2-3; 2nd column, 2nd row

"1.797693. . .E+308" should be "-1.797693. . .E+308".

Anonymous   
PDF Page 19
Table 2-3

Initial '-' missing in definition of 'Double'.

'1.7976931348623157E+308' should be '-1.7976931348623157E+308'

Paul Pype  Jan 01, 2009 
Printed Page 24
1st CREATE TABLE statement

"address VARCHAR(30)" should be "street VARCHAR(30)"

Anonymous   
Printed Page 25
All of page

"address" should be replaced with "street".

Anonymous   
Printed Page 26
CREATE TABLE statement

"fk_person_id" should be "fk_favorite_food".

Anonymous   
Printed Page 30
4th INSERT statement on the page

"address" should be replaced with "street".

Anonymous   
Printed Page 32
'Column Value Violations' & 'Invalid Date Conversions'

I am running MYSQL version 14.12 Distrib 5.0.22.
The author comments that on the errors mentioned above, MYSQL produces 'Soft Errors'.
It appears that this has been changed to reject the invalid entries on the version of
MYSQL I am running (see above).

Anonymous   
Printed Page 32
Nonexistent Foreign Key

mysql Ver 14.12 Distrib 5.0.24a, for unknown-openbsd3.9 (i386) using readline 4.3

mysql> show tables;
+---------------------------+
| Tables_in_chapter2_person |
+---------------------------+
| favorite_food |
| person |
+---------------------------+
2 rows in set (0.00 sec)

mysql> desc favorite_food;
+-----------+----------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+----------------------+------+-----+---------+-------+
| person_id | smallint(5) unsigned | NO | PRI | 0 | |
| food | varchar(20) | NO | PRI | | |
+-----------+----------------------+------+-----+---------+-------+
2 rows in set (0.01 sec)

mysql> desc person;
+-------------+----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+----------------------+------+-----+---------+----------------+
| person_id | smallint(5) unsigned | NO | PRI | NULL | auto_increment |
| fname | varchar(20) | YES | | NULL | |
| lname | varchar(20) | YES | | NULL | |
| gender | enum('M','F') | YES | | NULL | |
| birth_date | date | YES | | NULL | |
| address | varchar(30) | YES | | NULL | |
| city | varchar(20) | YES | | NULL | |
| state | varchar(20) | YES | | NULL | |
| country | varchar(20) | YES | | NULL | |
| postal_code | varchar(20) | YES | | NULL | |
+-------------+----------------------+------+-----+---------+----------------+
10 rows in set (0.01 sec)

mysql> select * from person;
+-----------+---------+--------+--------+------------+------------------+--------
+-------+---------+-------------+
| person_id | fname | lname | gender | birth_date | address | city |
state | country | postal_code |
+-----------+---------+--------+--------+------------+------------------+--------
+-------+---------+-------------+
| 1 | William | Turner | M | 1972-05-27 | 1224 Tremont St. | Boston | MA
| USA | 02138 |
+-----------+---------+--------+--------+------------+------------------+--------
+-------+---------+-------------+
1 row in set (0.00 sec)

mysql> select * from favorite_food;
+-----------+---------+
| person_id | food |
+-----------+---------+
| 1 | cookies |
| 1 | nachos |
| 1 | pizza |
+-----------+---------+
3 rows in set (0.00 sec)

mysql> insert into favorite_food (person_id, food) -> values (999, 'lasagna');
Query OK, 1 row affected (0.00 sec)

This last insert shouldn't happen, should it?

Anonymous   
Printed Page 34
table 2-9

branch definition omitted from table

Anonymous   
Printed Page 45, 46
2nd paragraph

The 'Trap' note at the top of page 46 should be moved to before the section on 'Views' on page 45. This is due to the fact that someone following along with the book, and has a version of MySQL prior to 5.0.1 may get stuck trying to sort out why they generate a syntax error in MySQL trying to put in the example for Views, and would not know why till the next page. (I.E. They would keep trying to fix their syntax, before turning the page and seeing the explanation of why it does not work in versions prior to 5.0.1.)

Anonymous   
Printed Page 55
Exercise 3-4

To get the proper requested output, the query should include
an ORDER BY clause since the output is sorted.

SELECT p.product_cd, a.cust_id, a.avail_balance
FROM product p INNER JOIN account <1>
ON p.product_cd = <2>
WHERE p.<3> = 'ACCOUNT'
ORDER BY p.product_cd;

Anonymous   
Printed Page 101
1st paragraph

A sentence in this paragraph reads: "In every example thus far in the chapter, the
column names have been the same for both queries in the compound query. . ." This is
not a true statement for this chapter.

Anonymous   
Printed Page 112
1st row

"13" should be "8".

Anonymous   
Printed Page 120
3rd code block from top (also 2nd text paragraph from bottom)

Book reports that ROUND(72.5) in mySQL equals 72. My replication of the example gives
an answer of 73 for ROUND(72.5).

From Book:
mysql> SELECT ROUND(72.49999),ROUND(72.5),ROUND(72.50001);
+-----------------+-------------+-----------------+
| ROUND(72.49999) | ROUND(72.5) | ROUND(72.50001) |
+-----------------+-------------+-----------------+
| 72 | 72 | 73 |
+-----------------+-------------+-----------------+
1 row in set (0.00 sec)

My prompt:
LearningSQL> SELECT ROUND(72.49999),ROUND(72.5),ROUND(72.50001);
+-----------------+-------------+-----------------+
| ROUND(72.49999) | ROUND(72.5) | ROUND(72.50001) |
+-----------------+-------------+-----------------+
| 72 | 73 | 73 |
+-----------------+-------------+-----------------+
1 row in set (0.03 sec)

Anonymous   
Printed Page 142
3rd paragraph. last sentence

Instead of

"The difference is that count(*) counts the number of rows and is thus UNAFFECTED by any null values contained in a row, while count(val) counts the number of values contained in the val column and ignores any null values encountered"

it should be

"The difference is that count(*) counts the number of rows and is thus AFFECTED by any null values contained in a row, while count(val) counts the number of values contained in the val column and ignores any null values encountered"

(caps mine for clarity)

As written, it restates the same thing, whereas the first part of the sentence should be changed to show the converse.

Anonymous   
Printed Page 148
last section before excercises

I apologize in advance if I'm simply misunderstanding this section.

When I execute this query, it returns 2 rows. One for product_cd MM and one for product_cd CD. The book shows 1 row for MM. It makes sense for CD to also be included since the avail_balance for the 3 CD accounts are: 3000, 10000, 5000, 1500.

The last sentence reads: "...the filter condition in the having clause excludes all groups whose minimum balance is less than 1000 or whose maximum balance is greater than 10000."

Shouldn't it read: "...the filter condition in the having clause excludes all ROWS whose minimum balance is less than 1000 or whose maximum balance is greater than 10000." ?

Anonymous   
Printed Page 150
Second paragraph, unordered list

The list includes three table formats that a subquery can return. There is a fourth:
* A single row with multiple columns

Anonymous   
Printed Page 159
2nd paragraph

". . .uses this information to retrieve all checking accounts opened by a head teller
at the . . ." should be ". . .uses this information to retrieve all accounts opened
by a teller at the . . ."

Anonymous   
Printed Page 159
2nd paragraph

The assertion is made that the query at the two queries on the page are equivalent. Although they give the same results from the sample database, they are not equivalent. The purpose of the queries seems to be to retrieve accounts that are opened by Tellers and Head Tellers at the Wobern Branch. However, the second query contains a join between the branch and employee table. The join further restricts the query to tellers and head tellers that are currently assigned to the Woburn branch. Consider the case in which an employee had be reassigned to a different branch. The first query would include accounts opened by that employee at their old branch while the second would omit those accounts. An equivalent second query would be:
SELECT account_id, product_cd, cust_id
FROM account
WHERE (open_branch_id, open_emp_id) IN
(SELECT b.branch_id, e.emp_id
FROM branch b, employee e
WHERE b.name = 'Woburn Branch'
AND (e.title = 'Teller' OR e.title = 'Head Teller'));

This version of the query omits the join between branch and employee.

Anonymous  Nov 05, 2008 
Printed Page 160
first sentence

I believe I have found a mistake, on pages 159-160 of my copy. Chapter 9:
Subqueries: the section on Multicolumn Subqueries. I have never used multicolumn
subqueries before, so perhaps there is some subtlety I am missing, but this doesn't
look right to me.

You have two examples, one using multiple single-column subqueries and one using a
single multi-column subquery. Discussing the second version, you state, "This
version of the query performs the same function as the previous example." However, I
do not think that is the case. I will reproduce both queries here, just in case you
haven't memorized every single line of your entire book :)

select account_id, product_cd, cust_id
from account
where open_branch_id = (select branch_id
from branch
where name = 'Woburn Branch')
and open_emp_id in (select emp_id
from employee
where title = 'Teller' or title = 'Head Teller');

As you can see, this query will return all of the accounts which were opened in the
Woburn branch by a Teller/Head Teller. However, there is nothing in this query to
restrict the list of Tellers to only those in the Woburn branch. Now, the second
query:

select account_id, product_cd, cust_id
from account
where (open_branch_id, open_emp_id) in
(select b.branch_id, e.emp_id
from branch b inner join employee e
on b.branch_id = e.assigned_branch_id
where b.name = 'Woburn Branch'
and (e.title = 'Teller' or e.title = 'Head Teller'));

Here, we are joining the branch table to the employee table on the assigned_branch_id
field. Our set of employees used to be restricted to those with Teller or Head
Teller for a title. Now we have an additional restriction: only employees who are
currently assigned to the Woburn Branch. This is substantially different from the
first query.

It is true that the two queries returned the same results for this particular
dataset, but only because the data did not include an example of a Teller in the
Woburn Branch opening an account and then being transferred to a different branch.

Anonymous   
Printed Page 166
1st paragraph

The first sentence should read:
"...to retrieve all accounts opened by a teller at the Woburn branch"

The sentence currently reads:
"...to retrieve all CHECKING accounts opened by a teller at the Woburn branch"

The word "checking" is incorrect".


Anonymous  Dec 28, 2012 
Printed Page 169
2nd paragraph

The first query on page 169 is supposed to return basically the same data as the longer query on the previous page (168). But it returns 3 extra rows, 14 rows vs. 12 for the page 168 query.

The error is that the shorter query on page 169 does not include a JOIN and WHERE clause that is included on page 168. The text states that the only reason for the JOINs on the page 168 query is to get the display text (ie, for employee names from the emp_id, etc), but the other reason for the JOINs is to include the WHERE clause mentioned above. If you include the missing WHERE clause, the query on page 169 returns the same results as the query on page 168. This modification worked perfectly for me on my system:

select a.product_cd, a.open_branch_id, a.open_emp_id, sum(a.avail_balance)
from account a
join product p
on a.product_cd = p.product_cd
where p.product_type_cd = 'ACCOUNT'
group by a.product_cd, a.open_branch_id, a.open_emp_id;

Also, the second query on page 169, which is also supposed to return the same data as the query on page 168 and first query on page 169, has a minor error in that the order of the result set is not sorted the same way as the result set returned from the query on page 168.

This is probably caused by the lack of an ORDER BY clause on both queries, and the details of the MYSQL implementation, due to the order of a result set being undefined in SQL without an ORDER BY clause. As far as I can see, the data for this query is correct, only the sort order is wrong; but its still confusing when trying to compare the query results, which should ideally be identical.

Anonymous   
Printed Page 169
2nd paragraph

The first query on page 169 is supposed to return basically the same data as the longer query on the previous page (168). But it returns 3 extra rows, 14 rows vs. 12 for the page 168 query.

The error is that the shorter query on page 169 does not include a JOIN and WHERE clause that is included on page 168. The text states that the only reason for the JOINs on the page 168 query is to get the display text (ie, for employee names from the emp_id, etc), but the other reason for the JOINs is to include the WHERE clause mentioned above. If you include the missing WHERE clause, the query on page 169 returns the same results as the query on page 168. This modification worked perfectly for me on my system:

select a.product_cd, a.open_branch_id, a.open_emp_id, sum(a.avail_balance)
from account a
join product p
on a.product_cd = p.product_cd
where p.product_type_cd = 'ACCOUNT'
group by a.product_cd, a.open_branch_id, a.open_emp_id;

Also, the second query on page 169, which is also supposed to return the same data as the query on page 168 and first query on page 169, has a minor error in that the order of the result set is not sorted the same way as the result set returned from the query on page 168.

This is probably caused by the lack of an ORDER BY clause on both queries, and the details of the MYSQL implementation, due to the order of a result set being undefined in SQL without an ORDER BY clause. As far as I can see, the data for this query is correct, only the sort order is wrong; but its still confusing when trying to compare the query results, which should ideally be identical.

Anonymous  Jun 05, 2008 
Printed Page 172
2nd SELECT statement

"FROM employee boss" appears twice in this statement and both are incorrect.

Anonymous   
Printed, PDF Page 173
bottom of page and on page 174

The table alias "groups" used in this query is a reserved word as of 8.0.2

Peter Fales  Apr 03, 2021 
Printed Page 180
under the section Left Versus Right Outer Joins the sentence:

On page 180 under the section Left Versus Right Outer Joins the sentence:

"The keyword left indicates that the table on the left side of the from
clause is responsible for determining...."

I believe it should read:

"The keyword left indicates that the table on the left side of the join
clause is responsible for determining...."

Anonymous  Mar 09, 2009 
Printed Page 199
1st Paragraph

The 2nd sentance starts "When the case expression is evaluated, the when clauses are evaluated in order from top to bottom; as soon as one of the conditions in a when clause evaluates to true, the corresponding expression is returned and any remaining when clauses are ignored".

This cannot be true since the example listed below the sentance returns both Individual names and Business names.

There are 2 "When" statements, the first is for the individual names and the 2nd is for the business names. If what is written in your sentance is true, you should have only returned Individual names.

Anonymous   
Printed Page 213
3rd paragraph

". . .server must complete before coming online is to find. . ." should be ". .
.server must complete after coming online is to find. . ."

Anonymous