-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMilestone2.sql
More file actions
90 lines (61 loc) · 1.97 KB
/
Milestone2.sql
File metadata and controls
90 lines (61 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
mysql-ctl cli
CREATE DATABASE ananya_db;
USE ananya_db;
CREATE TABLE shirts(
shirt_id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(shirt_id),
article VARCHAR(100),
color VARCHAR(100),
shirt_size VARCHAR(100),
last_worn INT
);
DESC shirts;
SHOW TABLES;
INSERT INTO shirts(article, color, shirt_size, last_worn) VALUES
('t-shirt', 'white', 'S', 10),
('t-shirt', 'green', 'S', 200),
('polo shirt', 'black', 'M', 10),
('tank top', 'blue', 'S', 50),
('t-shirt', 'pink', 'S', 0),
('polo shirt', 'red', 'M', 5),
('tank top', 'white', 'S', 200),
('tank top', 'blue', 'M', 15),
('purple', 'polo shirt', 'medium', 50);
SELECT * FROM shirts;
SELECT article,color FROM shirts;
SELECT* FROM shirts WHERE shirt_size='M';
SELECT article,color,shirt_size,last_worn FROM shirts WHERE shirt_size='M';
/*...Update...*/
/*.....Change size to ‘L’ for article 'polo shirt’.....*/
UPDATE shirts
SET shirt_size='L'
WHERE article='polo shirt';
/*............Output after update.........*/
SELECT * FROM shirts WHERE article='polo shirt';
/*... Change last_worn to 0 for any last_worn=15.... */
UPDATE shirts
SET last_worn=0
WHERE last_worn=15;
/*...........Output after update.........*/
SELECT * FROM shirts WHERE last_worn=0;
/*.....Change color to 'off white’ and shirt_size to 'XS’ wherever color is 'white’...*/
UPDATE shirts
SET color='off white',shirt_size='XS'
WHERE color='white';
/*...........Output after update.........*/
SELECT * FROM shirts WHERE shirt_size='XS';
/*....Print the complete updated shirts table...*/
SELECT * FROM shirts;
/*....Delete all the shirts which were worn equal/more than 200 days ago....*/
DELETE FROM shirts
WHERE last_worn>=200;
/*....print output table....*/
SELECT * FROM shirts;
/*....Delete all the tank tops and print output table....*/
DELETE FROM shirts
WHERE article='tank top';
SELECT * FROM shirts;
/*.......Delete all shirts without deleting the table.....*/
DELETE FROM shirts;
/*.... Showing empty set...*/
SELECT * FROM shirts;