-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql4.sql
More file actions
35 lines (23 loc) · 816 Bytes
/
sql4.sql
File metadata and controls
35 lines (23 loc) · 816 Bytes
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
use jsd2306;
delete
from jsdtn2306.tb_student;
delete
from jsdtn2306.tb_subject;
delete
from jsdtn2306.tb_student_subject;
insert into tb_student
values (1, 'Jack', 'male', 0, 'p1', 10000, '1990-09-12', '111', 'j@t.com', 2, now(), now(), null),
(2, 'Mike', 'male', 0, 'p2', 10000, '1990-09-12', '122', 'm@t.com', 2, now(), now(), null),
(3, 'Tony', 'male', 0, 'p2', 10000, '1990-09-12', '133', 't@t.com', 2, now(), now(), null);
insert into tb_subject
values (1, 'Java', null),
(2, 'MySQL', null);
insert into tb_student_subject
values (1, 1),
(1, 2),
(2, 1),
(2, 2);
select stu.name student_name, sub.name subject_name
from tb_student stu
left join tb_student_subject ss on stu.id = ss.student_id
join tb_subject sub on ss.subject_id = sub.id