Head First SQL by Lynn Beighley This errata page lists errors fixed in the November 2007 reprinting. If you have technical questions or error reports, you can send them to booktech@oreilly.com. Please specify the printing date of your copy. This page was updated January 24, 2008. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Confirmed errors: (xiv) Next to chapter 5 Heading in TOC, "ver" should be "Ever" (xxix) 3rd paragraph; "But we assume that if you're holding this book, you really want to learn about project management." "project management" should be "SQL" (xxxiv) 3rd paragraph, line 5; Missing period after "tennis" (15, 16) 3rd sentence, top of page; "Come up some likely columns for each table" should be "come up with some likely columns for each table." [25] in handwritten text at top of rightmost column; The text reads "These two numbers show how many digits the database should expect in front the decimal, and how many after." This is incorrect. It should read: "These two numbers show how many digits the database should expect, and how many after the decimal." {25} Table. First row, last column and legend; The description of the decimal type is wrong and the example number actually doesn't fit the datatype provided. The number before the comma in the DECIMAL data type is defined as the number of significant digits of the value. To store 5678.39, you would actually need DEC(6,2). MySQL accepts the value none the less, but a standards-compliant database should complain. {26} Table with solutions; tax_rate must be defined as dec(5,3) to hold values from 0.000 to 100.000 (99.999 being the significant number here) to correctly hold all the percentages in the format shown in the example. The provided solution dec(4,2) would not be sufficient to even hold the number provided in the question on page 25 because 3.755 requires three digits after the decimal point to store. {30} SQL Magnets Solution The CREATE DATABASE and USE DATABASE commands need to end in a semicolon (42) annotation in the middle of the page "We're using the the version..." should be "We're using the version..." {48} arrow pointing at DEC(3,2) This arrow should have a handwritten annotation that reads, "The total digits allowed are 3, with 1 before and 2 after the decimal." (53) 1st paragraph; "When it comes to databases, chances are you'll need to retrieve your data as often than you'll need to insert it." should read "When it comes to databases, chances are you'll need to retrieve your data as often as you'll need to insert it." {82} Solution to third query: Solution to third query should be the following: SELECT last_name, first_name, email FROM my_contacts WHERE location = 'San Antonio, TX' AND gender = 'M' AND status = 'single'; (86) first sentence; "So far we have only used the equal sign in our WHERE clause..." should be changed to "So far, we've mainly used the equal sign in our WHERE clause." {87} In the bottom right corner, should => be <= ? {89-90} bottom of the page -- last query; The text, "...without using the names of the drinks in your query." should be added to the end of the last question on the page. (93) 1st paragraph, 3rd sentence; "So, instead of two the two separate queries..." should be "So, instead of the two separate queries..." {104} Sixth WHERE clause from the top should only have one semicolon at the end. It should be: WHERE state LIKE 'M%' or state LIKE 'A%'; [115] Bottom of page; The solution: ... WHERE date_name NOT BETWEEN 'A' AND 'B'; returns 8 hits including Boris. The clause should be: ... WHERE date_name NOT BETWEEN 'A' and 'C'; {117} Single quote needed before the word "cherry" in fifth set of parentheses, Kiss on the Lips drink. (128) Answer to the last question.; Some of the best ones involving joins, a topic covered later in this book. should read: Some of the best ones involve joins, a topic covered later in this book. {130} Bottom of the page (last paragraph, in bold); Text currently reads: "You can use WHERE clauses with DELETE statements the same way you can use them with INSERT statements." In the statement above "INSERT" should be replaced with "SELECT". Hence the corrected statement should be: "You can use WHERE clauses with DELETE statements the same way you can use them with SELECT statements." {133-134} Final question The final question on page 133 and 134 should be: WHERE location = 'Snappy Bagel' OR rating = 3; {134} Answers to questions 4 and 6.; The arrows for Delete statement 4 point to the 1st, 3rd, and 4th row. They should point to the first, 2nd, and 4th row. Delete statement 6 says "No Matches, did not DELETE." This is incorrect; the 2nd row would be deleted. [NOTE: This correction to DELETE statement 6 is not needed if page 133 is corrected as listed above.] {135} bottom of page: Bottom big code block should be changed to: WHERE activities = 'yelling, dancing' AND name = 'Clarabelle'; [140] last_seen column: The last_seen column on this page should be changed to: lastSeen Cherry Hill Senior Center Jack Green's party Ball-mart Oakland Hospital* Belmont Senior Center Oakland Hospital Millstone Mall Earl's Autos Tracy's Millstone Mall Dickson Park* Ball-mart* Tracy's Dickson Park* Tracy's *changed This fixes problems with the exercise on page 141-142. [144] SELECT statement; Your SELECT throws an error. You need a star or column name before the FROM. In the first big code, the query should read: SELECT * FROM clown_info WHERE activities = 'dancing'; [147] First Answer in "There are no dumb questions"; The text currently reads: "Then every column in the SET clause in your table will be updated with the new value." This is wrong. It should read: "Every column specified in the SET clause for every row in your table will be updated with the new value." (156) 1st paragraph; The first sentence says "age column", but it should read "cost column". {156} First SQL query; For this SQL query, the follow line should not end with a semicolon: SET cost = cost + 1; The semicolon causes the UPDATE query to update all rows. {189-190} Third query on middle of page: Although the third query on 189 and 190 may work with some versions of MySQL, it throws a warning and some versions won't fix it. It should be changed to: INSERT INTO your_table VALUES (2, 'Bobby', 'Brady'); (210) middle; ADD PRIMARY KEY ('proj_id'); Should be without quotes, i.e. ADD PRIMARY KEY (proj_id) {277} In the crossword puzzle, the clue for 10 down should be: "Use this in a SELECT to return the total value of results rather rather than the results themselves." (279) Last line; The last line on the answer page on 279 does not match the last line on page 272. It should read, "How am I? Somewhere in the middle." {307} SQL command in middle of page; At the end of the CREATE TABLE command, the final closing parenthesis should come before the semicolon. {333} Final line of text: Final line of text in the instructions should read: "Finally, add these new columns to the appropriate tables: phone, manager, cost, and weight." {335} store_inventory table solution: The values in the first column, toy_id, in the store_inventory table need to be changed to: toy_id 1 2 3 4 5 6 7 8 9 10 (340) Note on "Foreign key": The note on "Foreign key" is wrong. The note printed describes third normal form instead of foreign key. The note should read, "A column in a table that references the primary key of another table." {356} SELECT proffession AS mcprof; Should be mc_prof NOT mcprof {360, 362} Last line of query: Last line of query should be changed from "ON mc.contact_id = p.prof_id;" to "ON mc.prof_id = p.prof_id;" {391-392} SQL's Rules of Order puzzle and solution: The words 'FROM' and 'HAVING' are used in the solution, but are not among the list of words for the puzzle. (392) Second question refers to page 388, this should be page 387. {399} annotations for top query diagram: Two of the annotations for the top query diagram should be changed to indicate that the subquery (inner query) is processed first. The top-left annotation should be changed from "The RDBMS processes this part first." to "The RDBMS processes this part second." And the bottom-right annotation should be changed from "This is processed second." to "This is processed first." (428) First sentence in thought bubble: "...use an outer join to to join a single..." should be "...use an outer join to join a single..." {458} Under "He gets the status_id from the status table" The second annotation on this page should be changed from "And here's the status_id that corresponds to 'married'." to "And here's the status_id that corresponds to 'single'." Also, the value in the result table for status_id should be 3, not 4. (465) tech_writer_jobs CREATE VIEW statement; There should be a ',' character after 'title' in the tech_writer_jobs CREATE VIEW statement. {490, 557} 'UPDATABLE VIEWS' tooltip; "...all NOT NULL rows of the base table..." should be "...all NOT NULL columns of the base table..." (518) GRANT statements at the bottom of the page; "GRANT SELECT ON my_contacts * TO frank;" should be "GRANT SELECT ON my_contacts.* TO frank;" "GRANT SELECT, INSERT ON gregs_list * TO jim;" should be "GRANT SELECT, INSERT ON gregs_list.* TO jim;" (520) First paragraph: "...Greg's List to include to include local..." should be "...Greg's List to include local..." {528} second table; Used the '+' sign for subtraction and division. Should be '-' and '/', respectively. {528} comparison operators table at the bottom of the page: 'Not less than' operator should be '!<' 'Less than or equal to' operator should be '<=' (530) Last paragraph; The last body text paragraph should read: "The query above will return Pizza House. We can also use >= and <= with ALL. The query below will give us both The Shack and Arthur's. We get the ratings greater than any in our set, as well as equal to the largest one in our set, which is 7:" (535) Last sentence; The last sentence of the page is nearly identical to the last sentence of the preceding section ('Some situations where you might want to use CAST()'). {537} "what does it do?" for the Log(x) and Log(x,y) functions The "what does it do?" text for the Log(x) and Log(x,y) functions should be changed to "Returns the natural logarithm of x, or with two parameters returns the log of y for base x." {541} Second to last highlighted code line at the bottom of the page; " lose($conn);" should be "mysql_close($conn);"