generated from Code-Institute-Org/gitpod-full-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.txt
134 lines (121 loc) · 4.82 KB
/
file.txt
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
mysql> show tables;
+-------------------+
| Tables_in_Chinook |
+-------------------+
| Album |
| Artist |
| Customer |
| Employee |
| Genre |
| Invoice |
| InvoiceLine |
| MediaType |
| Playlist |
| PlaylistTrack |
| Track |
+-------------------+
11 rows in set (0.00 sec)
mysql> desc Album;
+----------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+--------------+------+-----+---------+----------------+
| AlbumId | int | NO | PRI | NULL | auto_increment |
| Title | varchar(160) | NO | | NULL | |
| ArtistId | int | NO | MUL | NULL | |
+----------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
mysql> ^C
mysql> source test.sql
+----------+
| count(*) |
+----------+
| 3503 |
+----------+
1 row in set (0.00 sec)
+----------+
| count(*) |
+----------+
| 275 |
+----------+
1 row in set (0.00 sec)
mysql> USE Chinook;
Database changed
mysql> SELECT * FROM Album LIMIT 5;
+---------+---------------------------------------+----------+
| AlbumId | Title | ArtistId |
+---------+---------------------------------------+----------+
| 1 | For Those About To Rock We Salute You | 1 |
| 2 | Balls to the Wall | 2 |
| 3 | Restless and Wild | 2 |
| 4 | Let There Be Rock | 1 |
| 5 | Big Ones | 3 |
+---------+---------------------------------------+----------+
5 rows in set (0.01 sec)
mysql> SELECT Title, Name FROM Album
-> JOIN Artist ON ALbum.ArtistId = Artist.ArtistId
-> LIMIT 5;
ERROR 1054 (42S22): Unknown column 'ALbum.ArtistId' in 'on clause'
mysql> USE Chinook;
Database changed
mysql> SELECT * FROM Album LIMIT 5;
+---------+---------------------------------------+----------+
| AlbumId | Title | ArtistId |
+---------+---------------------------------------+----------+
| 1 | For Those About To Rock We Salute You | 1 |
| 2 | Balls to the Wall | 2 |
| 3 | Restless and Wild | 2 |
| 4 | Let There Be Rock | 1 |
| 5 | Big Ones | 3 |
+---------+---------------------------------------+----------+
5 rows in set (0.00 sec)
gitpod /workspace/mysql-test-2 $ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.26-0ubuntu0.20.04.3 (Ubuntu)
Copyright (c) 2000, 2021, 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 * FROM Arist LIMIT 5;
ERROR 1046 (3D000): No database selected
mysql> USE Chinook;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SELECT * FROM Artist LIMIT 5;
+----------+-------------------+
| ArtistId | Name |
+----------+-------------------+
| 1 | AC/DC |
| 2 | Accept |
| 3 | Aerosmith |
| 4 | Alanis Morissette |
| 5 | Alice In Chains |
+----------+-------------------+
5 rows in set (0.00 sec)
mysql> SELECT * FROM Album LIMIT 5;
+---------+---------------------------------------+----------+
| AlbumId | Title | ArtistId |
+---------+---------------------------------------+----------+
| 1 | For Those About To Rock We Salute You | 1 |
| 2 | Balls to the Wall | 2 |
| 3 | Restless and Wild | 2 |
| 4 | Let There Be Rock | 1 |
| 5 | Big Ones | 3 |
+---------+---------------------------------------+----------+
5 rows in set (0.00 sec)
mysql> SELECT Title, Name FROM Album
-> JOIN Artist ON Album.ArtistId = Artist.ArtistId
-> LIMIT 5;
+---------------------------------------+-----------+
| Title | Name |
+---------------------------------------+-----------+
| For Those About To Rock We Salute You | AC/DC |
| Balls to the Wall | Accept |
| Restless and Wild | Accept |
| Let There Be Rock | AC/DC |
| Big Ones | Aerosmith |
+---------------------------------------+-----------+
5 rows in set (0.01 sec)
mysql>