Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Student
- |-------------------------|
- | StudentID | Student_Name|
- |-------------------------|
- | 1 | John |
- | 2 | Sally |
- | 3 | Stan |
- ---------------------------
- Class
- ------------------------
- | ClassID | Class_Name|
- ------------------------
- | 1 | Math |
- | 2 | Physics |
- ------------------------
- Student_Class
- -----------------------
- | StudentID | ClassID |
- -----------------------
- INSERT INTO Student_Class (StudentID, ClassID) VALUES (1, 2);
- INSERT INTO Student_Class (StudentID, ClassID) VALUES (2, 1);
- INSERT INTO Student_Class (StudentID, ClassID) VALUES (3, 1);
- INSERT INTO Student_Class (StudentID, ClassID) VALUES (3, 2);
- SELECT Student.Student_Name,
- Class.Class_Name
- FROM Student,
- Class,
- Student_Class
- WHERE Student.StudentID = Student_Class.StudentID
- AND Class.ClassID = Student_Class.ClassID;
- ------------------------------
- | Student_Name | Class_Name |
- ------------------------------
- | John | Physics |
- | Sally | Math |
- | Stan | Physics |
- | Stan | Math |
- ------------------------------
- student { StudentID, StudentName ... }
- classes { ClassID, ClassName ... }
- student_classes { StudentID, ClassID }
- student_classes { StudentID, Year, ClassID }
- Student Table
- -------------
- id
- first_name
- last_name
- dob
- Class Table
- -----------
- id
- class_name
- academic_year
- Student_Class Table
- -------------------
- student_id
- class_id
- year_taken
- SELECT
- s.last_name + ', ' + s.first_name AS student_name,
- c.class_name,
- sc.year_taken
- FROM
- student s
- INNER JOIN
- student_class sc
- ON
- s.id = sc.student_id
- INNER JOIN
- class c
- ON
- sc.class_id = class.id
- ORDER BY
- s.last_name, sc.year_taken
- Student Table with the following columns
- StudentID
- StudentLastName
- StudentFirstName
- (and so forth for all the data to describe a student)
- Student Table with the following columns
- StudentID
- StudentLastName
- StudentFirstName
- (and so forth for all the data to describe a student)
- Course table with the following columns
- CourseId
- CourseName
- StudentCourse Table with the following columns
- StudentId
- CourseID
- CourseDate
- Select StudentID,StudentLastName,StudentFirstName, CourseName, CourseDate
- from Student
- join StudentCourse on student. studentid = StudentCourse.StudentID
- join Course on Course.courseID = StudentCourse.CourseID
Add Comment
Please, Sign In to add comment