Basic SQL - Student Information
Student Information
1. Select necessary tables:
To keep things clear, we should keep tables we need. Since we need (StudentName, CourseName),
we will keep table (b) CourseInfo and (c) StudentInfo. We also have to filter based on grade, we
will also bring table (d) StudentGrades.
2. Find connections:
Now we need to know how are tables connected.
We can see that table (c) StudentInfo and (d) StudentGrades are connected in terms of the attribute
StudentID. The attribute CourseID is a connection for table (d) StudentGrades and (b) CourseInfo.
There is a yellow box for the attribute Grade because that will be used for WHERE clause.
3. Code:
For this case, we will use command SELECT, FROM, and WHERE. To keep the code simple,
we will define table StudentInfo as SI, CourseInfo as CN, and StudentGardse as SG and put them
after FROM because we are using those three tables. Since we want StudentName and
CourseName but they are from a different table, we will attach the simple table code before them
after SELECT. The most complicated part of this is to figure out what goes after WHERE. It's
simple! First, use the connection between tables and use AND to keep all the conditions together.
Since we need only A or A+ grades, we will also use that as a condition but remember to use OR
for that too. And this is the resulting code:
Then we get this result:






Comments
Post a Comment