2020年1月12日日曜日

おうちで学べるデータベースのきほんのハマったとこ

前提:第3版を読んでいます

p.182
都市の名称の最大値、最小値の部分

mysql> select max (name) from city where countrycode = 'JPN';
ERROR 1630 (42000): FUNCTION world.max does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual

何がエラーか解らなかったけど、、

mysql> select max(name) from city where countrycode='JPN';
+-----------+
| max(name) |
+-----------+
| Zama      |
+-----------+
1 row in set (0.01 sec)

答え:maxとカッコの間に半角空白が入っているとエラーになります。
冊子では明らかにスペースがあるんだけど…。

***** ----- ***** ----- *****

p.192
人口を更新するクエリ
mysql> update city set name = 'Kyoto',population = 1469069 where countrycode='JPN' and district = 'Kyoto' and name = 'Kioto';
Query OK, 0 rows affected (0.00 sec)

p.188のStep1でKyotoに変更しているので、この流れのままだと変更されません。
mysql> update city set name = 'Kyoto',population = 1469069 where countrycode='JPN' and district = 'Kyoto' and name = 'Kyoto';
が正しいです。

***** ----- ***** ----- *****

正誤表
https://www.shoeisha.co.jp/book/detail/9784798135168

0 件のコメント:

コメントを投稿