MySQL SQL 練習問題
This commit is contained in:
32
MYSQL_Question1.txt
Normal file
32
MYSQL_Question1.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
--問1
|
||||
CREATE TABLE book_table (
|
||||
book_id INT,
|
||||
book_name VARCHAR(50),
|
||||
author_name VARCHAR(50),
|
||||
price INT,
|
||||
sales_flag INT
|
||||
);
|
||||
|
||||
--問2
|
||||
INSERT INTO book_table VALUES(10001, 'TwoPeace', '三田英一郎', 420, 1);
|
||||
INSERT INTO book_table VALUES(10002, '名探偵金田二', '青山ふみや', 460, 1);
|
||||
INSERT INTO book_table VALUES(20001, '坊ちゃま', '冬目漱岩', 460, 1);
|
||||
INSERT INTO book_table VALUES(30001, '西方見聞録', '不明', 1000, 1);
|
||||
INSERT INTO book_table VALUES(40010, '吾輩は犬である', '冬目漱岩', 420
|
||||
, 1);
|
||||
|
||||
--問3
|
||||
SELECT book_name, author_name FROM book_table;
|
||||
|
||||
--問4
|
||||
UPDATE book_table SET author_name = 'マール=コー=ポロ', sales_flag = 0 WHERE book_id = 30001;
|
||||
|
||||
--問5
|
||||
select book_id, book_name, author_name, price, sales_flag from book_table where sales_flag = 1;
|
||||
|
||||
--問6
|
||||
select book_id, book_name, author_name, price, sales_flag from book_table where author_name = '冬目漱岩' and price = 420;
|
||||
|
||||
--問7
|
||||
delete from book_table where book_id = 20001;
|
||||
select * from book_table;
|
||||
Reference in New Issue
Block a user