-
Notifications
You must be signed in to change notification settings - Fork 0
/
shirtexample.sql
42 lines (34 loc) · 1.22 KB
/
shirtexample.sql
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
CREATE TABLE shirts (
shirt_id INT AUTO_INCREMENT PRIMARY KEY,
article VARCHAR(50),
color VARCHAR(50),
shirt_size VARCHAR(5),
last_worn INT
);
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';
DESC shirts;
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);
SELECT *FROM shirts;
INSERT INTO shirts (article, color, shirt_size, last_worn)
VALUES ('polo shirt','purple', 'M', 50);
SELECT *FROM shirts;
UPDATE shirts SET color = 'off white',shirt_size = 'XXS'WHERE color = 'white';
SELECT* FROM shirts;
-- drop delete all things
-- delete from just delete from table what you want to delete
-- SELECT * FROM shirts WHERE last_worn=200;
DELETE FROM shirts WHERE last_worn=200;
SELECT *FROM shirts;
-- SELECT * FROM shirts WHERE article='tank top';
-- DELETE FROM shirts WHERE article='tank top';