-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQUERIES.txt
47 lines (40 loc) · 2 KB
/
QUERIES.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
GETS THE ROOM CODE OF ALL GIVEN COURSES:
SELECT code, title, number FROM courses c
JOIN rooms r ON c.room_id = r.id
GETS ALL THE INSTRUCTORS AND WHAT COURSES DO THEY TEACH
SELECT code, title, first_name, last_name FROM course_by_instructor cbi
JOIN courses c ON cbi.course_id = c.id
JOIN users u ON cbi.user_id = u.id
GET THE COURSES THAT A SINGLE INSTRUCTOR IS TEACHING
SELECT code, title, first_name, last_name FROM course_by_instructor cbi
JOIN courses c ON cbi.course_id = c.id
JOIN users u ON cbi.user_id = u.id
WHERE u.first_name = 'Michel' AND u.last_name = 'Nabaa'
GETS ALL THE COURSES AND WHO IS TEACHING THEM AT WHAT TIME AND IN WHAT ROOM
SELECT code, title, first_name, last_name, start_date, end_date, number, day FROM course_by_instructor cbi
JOIN courses c ON cbi.course_id = c.id
JOIN users u ON cbi.user_id = u.id
JOIN time t ON c.time_id = t.id
JOIN rooms r ON c.room_id = r.id
JOIN days d ON c.day_id = d.id
GETS THE COURSES OF A SINGLE STUDENT
SELECT first_name, code, title, start_date, end_date, day FROM student_by_course sby
JOIN users u ON u.id = sby.student_id
JOIN courses c ON c.id = sby.course_id
JOIN time t ON t.id = c.time_id
JOIN days d ON d.id = c.day_id
WHERE sby.student_id = 1
GET ALL THE COURSES THAT THOSE STUDENTS TAKE AND STORE THE START DATE AND THE DAY IN A LIST
SELECT day ,start_date FROM student_by_course sby
JOIN courses c ON c.id = sby.course_id
JOIN rooms r ON r.id = c.room_id
JOIN days d ON d.id = c.day_id
JOIN users u ON u.id = sby.student_id
JOIN time t ON t.id = c.time_id WHERE u.type = 'a' AND sby.student_id IN (SELECT student_id
FROM student_by_course JOIN users u ON u.id = student_id WHERE course_id = "+Course_id+" AND u.type = 'a')"
GET THE ABSENCES OF A GIVEN DOCTOR
SELECT first_name, last_name, date FROM professor_absence pa JOIN users u ON pa.professor_id = u.id
WHERE u.first_name = 'Michel' AND u.last_name = 'Nabaa'
DELETE A COURSE
DELETE FROM courses WHERE courses.id = 3
DELETE FROM courses WHERE courses.title = 'Programming 1'