2 Commits

Author SHA1 Message Date
m-shimizu
a2ca833633 SLQ_Q2 2026-09-28 15:56:37 +09:00
m-shimizu
5bf83a28e4 SQL_Q1 2026-09-28 13:26:17 +09:00
4 changed files with 286 additions and 560 deletions

View File

@@ -1,169 +0,0 @@
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| rezodb |
+------------+
1 row in set (0.00 sec)
mysql> CREATE TABLE emp_table (emp_no INT, emp_name VARCHAR(50), salary INT);
Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO emp_table VALUES (1, '井上', 20000);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO emp_table VALUES (2, '梅田', 100000);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT *FROM emp_table;
+--------+----------+--------+
| emp_no | emp_name | salary |
+--------+----------+--------+
| 1 | 井上 | 20000 |
| 2 | 梅田 | 100000 |
+--------+----------+--------+
2 rows in set (0.00 sec)
mysql> CREATE TABLE book_table (book_id INT, book_name VARCHAR(50), author_name VARCHAR(50), price INT, sales_flag INT);
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO book_table VALUES (10001, 'TwoPeace', '三田英一郎', 420, 1);
ERROR 1054 (42S22): Unknown column ' 420' in 'field list'
mysql> INSERT INTO book_table VALUES (10001, 'TwoPeace', '三田英一郎', 420, 1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO book_table VALUES (10002, '名探偵金田二', '青山ふみや', 460, 1);
ERROR 1054 (42S22): Unknown column ' 460' in 'field list'
mysql> INSERT INTO book_table VALUES (10002, '名探偵金田二', '青山ふみや', 460, 1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO book_table VALUES (10003, '坊ちゃま', '冬目漱石', 460, 1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO book_table VALUES (10004, '西方見聞録', '不明', 1000, 1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO book_table VALUES (10005, '吾輩は犬である', '冬目漱石', 420, 1);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10003 | 坊ちゃま | 冬目漱石 | 460 | 1 |
| 10004 | 西方見聞録 | 不明 | 1000 | 1 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
5 rows in set (0.00 sec)
mysql> SELECT book_name FROM book_table;
+----------------+
| book_name |
+----------------+
| TwoPeace |
| 名探偵金田二 |
| 坊ちゃま |
| 西方見聞録 |
| 吾輩は犬である |
+----------------+
5 rows in set (0.00 sec)
mysql> SELECT book_name author_name FROM book_table;
+----------------+
| author_name |
+----------------+
| TwoPeace |
| 名探偵金田二 |
| 坊ちゃま |
| 西方見聞録 |
| 吾輩は犬である |
+----------------+
5 rows in set (0.00 sec)
mysql> SELECT book_name, author_name FROM book_table;
+----------------+-------------+
| book_name | author_name |
+----------------+-------------+
| TwoPeace | 三田英一郎 |
| 名探偵金田二 | 青山ふみや |
| 坊ちゃま | 冬目漱石 |
| 西方見聞録 | 不明 |
| 吾輩は犬である | 冬目漱石 |
+----------------+-------------+
5 rows in set (0.00 sec)
mysql> UPDATE book_table SET author_name = 'マール=コー=ポロ' SET sales_flag = 0 where book_id = 10004;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' SET sales_flag = 0 where book_id = 10004' at line 1
mysql> UPDATE book_table SET author_name = 'マール=コー=ポロ' where book_id = 10004;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE book_table ]SET sales_flag = 0 where book_id = 10004;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ']SET sales_flag = 0 where book_id = 10004' at line 1
mysql> UPDATE book_table SET sales_flag = 0 where book_id = 10004;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10003 | 坊ちゃま | 冬目漱石 | 460 | 1 |
| 10004 | 西方見聞録 | マール=コー=ポロ | 1000 | 0 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
5 rows in set (0.00 sec)
mysql> SELECT * FROM book_table where sales_flag = 1;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10003 | 坊ちゃま | 冬目漱石 | 460 | 1 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM book_table where author_name = '冬目漱石' AND price = 420;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' AND price = 420' at line 1
mysql> SELECT * FROM book_table where author_name = '冬目漱石' AND price = 420;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
1 row in set (0.00 sec)
mysql> DELETE FROM book_table WHERE book_id = 10003;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10004 | 西方見聞録 | マール=コー=ポロ | 1000 | 0 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
4 rows in set (0.00 sec)
mysql>

View File

@@ -0,0 +1,113 @@
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE TABLE book_table (
-> \c
mysql> ALTER TABLE book_table
-> ADD book_id INT,
-> ADD bookname VARCHAR(50),
-> ADD author_name VARCHAR(50),
-> ADD price INT,
-> ADD sales,flag INT;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ',flag INT' at line 6
mysql> ALTER TABLE book_table
-> -> ADD book_id INT,
-> -> ADD bookname VARCHAR(50),
-> -> ADD author_name VARCHAR(50),
-> -> ADD price INT,
-> -> ADD price INT,\c
mysql> ALTER TABLE book_table
-> ADD book_id INT,
-> ADD book_name VARCHAR(50),
-> ADD author_name VARCHAR(50),
-> ADD price INT,
-> ADD sales_flag INT;
ERROR 1146 (42S02): Table 'book_table.book_table' doesn't exist
mysql> SHOW TABLE;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql> SHOW TABLES;
Empty set (0.00 sec)
mysql> CREATE TABLE book_table (
-> book_id INT,
-> book_name VARCHAR(50),
-> author_name VARCHAR(50),
-> price INT,
-> sales_flag INT
-> );
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO book_table
-> VALUES(10001, 'TwoPeace', '三田英一郎', 420, 1),
-> (10002, '名探偵金田二', '青山ふみや', 460, 1),
-> (20001, '坊ちゃま', '冬目漱岩', 460, 1),
-> (30001, '西方見聞録', '不明', 1000, 1),
-> (40010, '吾輩は犬である', '冬目漱岩', 420, 1);
Query OK, 5 rows affected (0.02 sec)
Records: 5 Duplicates: 0 Warnings: 0
mysql> SELECT book_name, author_name FROM book_table;
+----------------+-------------+
| book_name | author_name |
+----------------+-------------+
| TwoPeace | 三田英一郎 |
| 名探偵金田二 | 青山ふみや |
| 坊ちゃま | 冬目漱岩 |
| 西方見聞録 | 不明 |
| 吾輩は犬である | 冬目漱岩 |
+----------------+-------------+
5 rows in set (0.00 sec)
mysql> UPDATE book_table SET author_name = 'マール=コーニポロ', salse_flag = 0 WHERE book_id = 30001;
ERROR 1054 (42S22): Unknown column 'salse_flag' in 'field list'
mysql> UPDATE book_table SET author_name = 'マール=コーニポロ', sales_flag = 0 WHERE book_id = 30001;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM book_table WHERE sales_flag = 1;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 20001 | 坊ちゃま | 冬目漱岩 | 460 | 1 |
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM book_table WHERE author
-> _name = '冬目漱岩' AND price = 420;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '_name = '冬目漱岩' AND price = 420' at line 2
mysql> SELECT * FROM book_table WHERE author_name = '冬目漱岩' AND price = 420;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
1 row in set (0.01 sec)
mysql> DELETE FROM book_table WHERE book_id = 20001;
Query OK, 1 row affected (0.02 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 30001 | 西方見聞録 | マール=コーニポロ | 1000 | 0 |
| 40010 | 吾輩は犬である | 冬目漱岩 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
4 rows in set (0.00 sec)
mysql>

View File

@@ -0,0 +1,173 @@
mysql> CREATE TABLE item_category( category_id. INT PRIMARY KEY AUTO_INCREMENT, category_name VARCHAR(256) NOT NULL);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '. INT PRIMARY KEY AUTO_INCREMENT, category_name VARCHAR(256) NOT NULL)' at line 1
mysql> CREATE TABLE item_category ( category_id, INT PRIMARY KEY AUTO_INCREMENT, category_name VARCHAR(256) NOT NULL);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ', INT PRIMARY KEY AUTO_INCREMENT, category_name VARCHAR(256) NOT NULL)' at line 1
mysql> CREATE TABLE item_category ( category_id INT PRIMARY KEY AUTO_INCREMENT, category_name VARCHAR(256) NOT NULL);
Query OK, 0 rows affected (0.03 sec)
mysql> DESC item_category;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| category_id | int | NO | PRI | NULL | auto_increment |
| category_name | varchar(256) | NO | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
2 rows in set (0.02 sec)
mysql> SELECT * FROM item_category;
Empty set (0.00 sec)
mysql> INSERT INTO item_category ( category_name ) VALUES ('家具'),('飲料'),('食品');
Query OK, 3 rows affected (0.01 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM item_category;
+-------------+---------------+
| category_id | category_name |
+-------------+---------------+
| 1 | 家具 |
| 2 | 飲料 |
| 3 | 食品 |
+-------------+---------------+
3 rows in set (0.00 sec)
mysql> CREATE TABLE items ( item_id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(256) NOT NULL,
-> price INT NOT NULL, category_id INT, FOREIGN KEY ( categry_id) REFERENCES item_category(category_id));
ERROR 1072 (42000): Key column 'categry_id' doesn't exist in table
mysql> CREATE TABLE items ( item_id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(256) NOT NULL,
-> price INT NOT NULL, category_id INT, FOREIGN KEY ( categry_id ) REFERENCES item_category( category_id ));
ERROR 1072 (42000): Key column 'categry_id' doesn't exist in table
mysql> CREATE TABLE items ( item_id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(256) NOT NULL,
-> price INT NOT NULL, category_id INT, FOREIGN KEY ( category_id ) REFERENCES item_category( category_id ));
Query OK, 0 rows affected (0.06 sec)
mysql> DESC items;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| item_id | int | NO | PRI | NULL | auto_increment |
| name | varchar(256) | NO | | NULL | |
| price | int | NO | | NULL | |
| category_id | int | YES | MUL | NULL | |
+-------------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
mysql> INSERT INTO items ( name, price, category_id )
-> VALUES ('ローマのテーブル', 150000, 1),('げーたるーど2000 500ml', 370, 2),('原始肉', 2500, 3),('魅惑の椅子', 100000, 1);
Query OK, 4 rows affected (0.01 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM items;
+---------+------------------------+--------+-------------+
| item_id | name | price | category_id |
+---------+------------------------+--------+-------------+
| 1 | ローマのテーブル | 150000 | 1 |
| 2 | げーたるーど2000 500ml | 370 | 2 |
| 3 | 原始肉 | 2500 | 3 |
| 4 | 魅惑の椅子 | 100000 | 1 |
+---------+------------------------+--------+-------------+
4 rows in set (0.00 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id;
+-------------+---------+------------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
| 2 | 2 | げーたるーど2000 500ml | 370 | 飲料 |
| 3 | 3 | 原始肉 | 2500 | 食品 |
+-------------+---------+------------------------+--------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id
-> ORDER BY items.price ASC;
+-------------+---------+------------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------------+--------+---------------+
| 2 | 2 | げーたるーど2000 500ml | 370 | 飲料 |
| 3 | 3 | 原始肉 | 2500 | 食品 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
+-------------+---------+------------------------+--------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id;
+-------------+---------+------------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
| 2 | 2 | げーたるーど2000 500ml | 370 | 飲料 |
| 3 | 3 | 原始肉 | 2500 | 食品 |
+-------------+---------+------------------------+--------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id
-> ORDER BY items.price ASC;
+-------------+---------+------------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------------+--------+---------------+
| 2 | 2 | げーたるーど2000 500ml | 370 | 飲料 |
| 3 | 3 | 原始肉 | 2500 | 食品 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
+-------------+---------+------------------------+--------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id
-> WHERE item_category.category_name = '家具';
+-------------+---------+------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
+-------------+---------+------------------+--------+---------------+
2 rows in set (0.00 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id
-> WHERE items.price BETWEEN 1000 AND 50000;
+-------------+---------+--------+-------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+--------+-------+---------------+
| 3 | 3 | 原始肉 | 2500 | 食品 |
+-------------+---------+--------+-------+---------------+
1 row in set (0.00 sec)
mysql> SELECT COUNT (*) AS data_count FROM items;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS data_count FROM items' at line 1
mysql> SELECT COUNT(*) AS data_count FROM items;
+------------+
| data_count |
+------------+
| 4 |
+------------+
1 row in set (0.01 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id
-> WHERE items.price = ( SELECT MAX(price) FROM items );
+-------------+---------+------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
+-------------+---------+------------------+--------+---------------+
1 row in set (0.00 sec)
mysql> SELECT items.category_id, items.item_id, items.name, items.price, item_category.category_name
-> FROM items JOIN item_category ON items.category_id = item_category.category_id
-> WHERE items.name LIKE '%の%';
+-------------+---------+------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
+-------------+---------+------------------+--------+---------------+
2 rows in set (0.00 sec)
mysql>

View File

@@ -1,391 +0,0 @@
Enter password: *********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> SELECT DATABASE();
+------------+
| DATABASE() |
+------------+
| rezodb |
+------------+
1 row in set (0.00 sec)
mysql> CREATE TABLE emp_table (emp_no INT, emp_name VARCHAR(50), salary INT);
Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO emp_table VALUES (1, '井上', 20000);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO emp_table VALUES (2, '梅田', 100000);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT *FROM emp_table;
+--------+----------+--------+
| emp_no | emp_name | salary |
+--------+----------+--------+
| 1 | 井上 | 20000 |
| 2 | 梅田 | 100000 |
+--------+----------+--------+
2 rows in set (0.00 sec)
mysql> CREATE TABLE book_table (book_id INT, book_name VARCHAR(50), author_name VARCHAR(50), price INT, sales_flag INT);
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO book_table VALUES (10001, 'TwoPeace', '三田英一郎', 420, 1);
ERROR 1054 (42S22): Unknown column ' 420' in 'field list'
mysql> INSERT INTO book_table VALUES (10001, 'TwoPeace', '三田英一郎', 420, 1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO book_table VALUES (10002, '名探偵金田二', '青山ふみや', 460, 1);
ERROR 1054 (42S22): Unknown column ' 460' in 'field list'
mysql> INSERT INTO book_table VALUES (10002, '名探偵金田二', '青山ふみや', 460, 1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO book_table VALUES (10003, '坊ちゃま', '冬目漱石', 460, 1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO book_table VALUES (10004, '西方見聞録', '不明', 1000, 1);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO book_table VALUES (10005, '吾輩は犬である', '冬目漱石', 420, 1);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10003 | 坊ちゃま | 冬目漱石 | 460 | 1 |
| 10004 | 西方見聞録 | 不明 | 1000 | 1 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
5 rows in set (0.00 sec)
mysql> SELECT book_name FROM book_table;
+----------------+
| book_name |
+----------------+
| TwoPeace |
| 名探偵金田二 |
| 坊ちゃま |
| 西方見聞録 |
| 吾輩は犬である |
+----------------+
5 rows in set (0.00 sec)
mysql> SELECT book_name author_name FROM book_table;
+----------------+
| author_name |
+----------------+
| TwoPeace |
| 名探偵金田二 |
| 坊ちゃま |
| 西方見聞録 |
| 吾輩は犬である |
+----------------+
5 rows in set (0.00 sec)
mysql> SELECT book_name, author_name FROM book_table;
+----------------+-------------+
| book_name | author_name |
+----------------+-------------+
| TwoPeace | 三田英一郎 |
| 名探偵金田二 | 青山ふみや |
| 坊ちゃま | 冬目漱石 |
| 西方見聞録 | 不明 |
| 吾輩は犬である | 冬目漱石 |
+----------------+-------------+
5 rows in set (0.00 sec)
mysql> UPDATE book_table SET author_name = 'マール=コー=ポロ' SET sales_flag = 0 where book_id = 10004;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' SET sales_flag = 0 where book_id = 10004' at line 1
mysql> UPDATE book_table SET author_name = 'マール=コー=ポロ' where book_id = 10004;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> UPDATE book_table ]SET sales_flag = 0 where book_id = 10004;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ']SET sales_flag = 0 where book_id = 10004' at line 1
mysql> UPDATE book_table SET sales_flag = 0 where book_id = 10004;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10003 | 坊ちゃま | 冬目漱石 | 460 | 1 |
| 10004 | 西方見聞録 | マール=コー=ポロ | 1000 | 0 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
5 rows in set (0.00 sec)
mysql> SELECT * FROM book_table where sales_flag = 1;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10003 | 坊ちゃま | 冬目漱石 | 460 | 1 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM book_table where author_name = '冬目漱石' AND price = 420;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' AND price = 420' at line 1
mysql> SELECT * FROM book_table where author_name = '冬目漱石' AND price = 420;
+---------+----------------+-------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+-------------+-------+------------+
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+-------------+-------+------------+
1 row in set (0.00 sec)
mysql> DELETE FROM book_table WHERE book_id = 10003;
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM book_table;
+---------+----------------+--------------------+-------+------------+
| book_id | book_name | author_name | price | sales_flag |
+---------+----------------+--------------------+-------+------------+
| 10001 | TwoPeace | 三田英一郎 | 420 | 1 |
| 10002 | 名探偵金田二 | 青山ふみや | 460 | 1 |
| 10004 | 西方見聞録 | マール=コー=ポロ | 1000 | 0 |
| 10005 | 吾輩は犬である | 冬目漱石 | 420 | 1 |
+---------+----------------+--------------------+-------+------------+
4 rows in set (0.00 sec)
mysql> CREATE TABLE item_category (category_id INT, category_name VARCHAR(256));
Query OK, 0 rows affected (0.03 sec)
mysql> INSERT INTO item_category (1, '家具');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1, '家具')' at line 1
mysql> INSERT INTO item_category (1, '家具');
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1, '家具')' at line 1
mysql> INSERT INTO item_category VALUES (1, '家具');
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO item_category VALUES (2, '飲料');
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO item_category VALUES (3, '食品');
Query OK, 1 row affected (0.00 sec)
mysql> SELECT * FROM item_table
-> ^C
mysql> SELECT * FROM item_table;
ERROR 1146 (42S02): Table 'rezodb.item_table' doesn't exist
mysql> SELECT * FROM item_category;
+-------------+---------------+
| category_id | category_name |
+-------------+---------------+
| 1 | 家具 |
| 2 | 飲料 |
| 3 | 食品 |
+-------------+---------------+
3 rows in set (0.00 sec)
mysql> CREATE TABLE items(item_id INT, name VARCHAR(256), price INT, category_id INT);
Query OK, 0 rows affected (0.02 sec)
mysql> INSERT INTO items VALUES (1, 'ローマのテーブル' 150000, 1);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 150000, 1)' at line 1
mysql> INSERT INTO items VALUES (1, 'ローマのテーブル', 150000, 1);
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO items VALUES (2, 'げーたるーど2000 500ml', 370, 2);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO items VALUES (3, '原子肉', 2500, 3);
Query OK, 1 row affected (0.01 sec)
mysql> INSERT INTO items VALUES (4, '魅惑の椅子', 100000, 1);
Query OK, 1 row affected (0.01 sec)
mysql> SELECT * FROM item;
ERROR 1146 (42S02): Table 'rezodb.item' doesn't exist
mysql> SELECT * FROM items;
+---------+------------------------+--------+-------------+
| item_id | name | price | category_id |
+---------+------------------------+--------+-------------+
| 1 | ローマのテーブル | 150000 | 1 |
| 2 | げーたるーど2000 500ml | 370 | 2 |
| 3 | 原子肉 | 2500 | 3 |
| 4 | 魅惑の椅子 | 100000 | 1 |
+---------+------------------------+--------+-------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM item_category INNER JOIN item ON item_category.category_id = item.category_id;
ERROR 1146 (42S02): Table 'rezodb.item' doesn't exist
mysql> SELECT * FROM item_category INNER JOIN item ON item_category.category_id = items.category_id;
ERROR 1146 (42S02): Table 'rezodb.item' doesn't exist
mysql> SELECT * FROM item_category INNER JOIN items ON item_category.category_id = items.category_id;
+-------------+---------------+---------+------------------------+--------+-------------+
| category_id | category_name | item_id | name | price | category_id |
+-------------+---------------+---------+------------------------+--------+-------------+
| 1 | 家具 | 1 | ローマのテーブル | 150000 | 1 |
| 2 | 飲料 | 2 | げーたるーど2000 500ml | 370 | 2 |
| 3 | 食品 | 3 | 原子肉 | 2500 | 3 |
| 1 | 家具 | 4 | 魅惑の椅子 | 100000 | 1 |
+-------------+---------------+---------+------------------------+--------+-------------+
4 rows in set (0.00 sec)
mysql> SELECT item.category.category_id AS items.category_id FROM item_category INNER JOIN item ON item_category.category_id = items.category_id;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.category_id FROM item_category INNER JOIN item ON item_category.category_id = i' at line 1
mysql> SELECT * FROM item_category INNER JOIN items ON item_category.category_id = items.category_id;
+-------------+---------------+---------+------------------------+--------+-------------+
| category_id | category_name | item_id | name | price | category_id |
+-------------+---------------+---------+------------------------+--------+-------------+
| 1 | 家具 | 1 | ローマのテーブル | 150000 | 1 |
| 2 | 飲料 | 2 | げーたるーど2000 500ml | 370 | 2 |
| 3 | 食品 | 3 | 原子肉 | 2500 | 3 |
| 1 | 家具 | 4 | 魅惑の椅子 | 100000 | 1 |
+-------------+---------------+---------+------------------------+--------+-------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM item_category INNER JOIN items ON USING (category_id);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING (category_id)' at line 1
mysql> SELECT * FROM item_category INNER JOIN items ON USING (category_id);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING (category_id)' at line 1
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id);
+-------------+---------+------------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
| 2 | 2 | げーたるーど2000 500ml | 370 | 飲料 |
| 3 | 3 | 原子肉 | 2500 | 食品 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
+-------------+---------+------------------------+--------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM items;
+---------+------------------------+--------+-------------+
| item_id | name | price | category_id |
+---------+------------------------+--------+-------------+
| 1 | ローマのテーブル | 150000 | 1 |
| 2 | げーたるーど2000 500ml | 370 | 2 |
| 3 | 原子肉 | 2500 | 3 |
| 4 | 魅惑の椅子 | 100000 | 1 |
+---------+------------------------+--------+-------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) OEDER BY price ASC;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OEDER BY price ASC' at line 1
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) ORDER BY price ASC;
+-------------+---------+------------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------------+--------+---------------+
| 2 | 2 | げーたるーど2000 500ml | 370 | 飲料 |
| 3 | 3 | 原子肉 | 2500 | 食品 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
+-------------+---------+------------------------+--------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE category_name = '家具';
+-------------+---------+------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
+-------------+---------+------------------+--------+---------------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE price > 1000 AND price < 50000;
+-------------+---------+--------+-------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+--------+-------+---------------+
| 3 | 3 | 原子肉 | 2500 | 食品 |
+-------------+---------+--------+-------+---------------+
1 row in set (0.00 sec)
mysql> SELECT COUNT (*) AS data_count from items;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS data_count from items' at line 1
mysql> SELECT COUNT () AS data_count from items;
ERROR 1630 (42000): FUNCTION rezodb.COUNT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual
mysql> SELECT COUNT (*) AS data_count from items;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS data_count from items' at line 1
mysql> SELECT COUNT (*) AS data_count FROM items;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) AS data_count FROM items' at line 1
mysql> SELECT COUNT (*) FROM items;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) FROM items' at line 1
mysql> SELECT COUNT(*) FROM items;
+----------+
| COUNT(*) |
+----------+
| 4 |
+----------+
1 row in set (0.01 sec)
mysql> SELECT COUNT(*) AS data_count FROM items;
+------------+
| data_count |
+------------+
| 4 |
+------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) s
-> ^C
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE score = MIN (score)
-> ^C
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE score = MIN (score);
ERROR 1054 (42S22): Unknown column 'score' in 'where clause'
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE score = (MIN (score) FROM items);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM items)' at line 1
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE score = (MIN(score) FROM items);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM items)' at line 1
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE score = (MAX(price) FROM items);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM items)' at line 1
mysql> mysql> SELECT * FROM items WHERE price = (SELECT MAX(price) FROM items);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql> SELECT * FROM items WHERE price = (SELECT MAX(price) FROM items)' at line 1
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id);
+-------------+---------+------------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
| 2 | 2 | げーたるーど2000 500ml | 370 | 飲料 |
| 3 | 3 | 原子肉 | 2500 | 食品 |
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
+-------------+---------+------------------------+--------+---------------+
4 rows in set (0.00 sec)
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE price = (MAX(price) FROM items);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM items)' at line 1
mysql> SELECT * FROM items WHERE price = (SELECT MAX(price) FROM items);
+---------+------------------+--------+-------------+
| item_id | name | price | category_id |
+---------+------------------+--------+-------------+
| 1 | ローマのテーブル | 150000 | 1 |
+---------+------------------+--------+-------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE price = (SELECT MAX(price) FROM items);
+-------------+---------+------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------+--------+---------------+
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
+-------------+---------+------------------+--------+---------------+
1 row in set (0.00 sec)
mysql> SELECT * FROM items INNER JOIN item_category USING (category_id) WHERE name LIKE '%の%';
+-------------+---------+------------------+--------+---------------+
| category_id | item_id | name | price | category_name |
+-------------+---------+------------------+--------+---------------+
| 1 | 4 | 魅惑の椅子 | 100000 | 家具 |
| 1 | 1 | ローマのテーブル | 150000 | 家具 |
+-------------+---------+------------------+--------+---------------+
2 rows in set (0.00 sec)
mysql>