

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of sql select queries, focusing on the use of distinct, where clauses, and joins to retrieve specific data from multiple tables. It includes examples and explanations of each concept, as well as their differences and applications.
Typology: Slides
1 / 25
This page cannot be seen from the preview
Don't miss anything!


















Last Smith Jones Brown Jones Brown
Last Smith Jones Brown
Grade ID Code Mark S103 DBS 72 S103 IAI 58 S104 PR1 68 S104 IAI 65 S106 PR2 43 S107 PR1 76 S107 PR2 60 S107 IAI 35
ID Mark S103 58 S104 65
Student ID First Last S103 John Smith S104 Mary Jones S105 Jane Brown S106 Mark Jones S107 John Brown
Grade ID Code Mark S103 DBS 72 S103 IAI 58 S104 PR1 68 S104 IAI 65 S106 PR2 43 S107 PR1 76 S107 PR2 60 S107 IAI 35
And then with the second…
and so on
Are matched with the first entry from the Student table...
All of the entries from the Grade table
ID First Last ID Code Mark S103 John Smith S103 DBS 72 S103 John Smith S103 IAI 58 S103 John Smith S104 PR1 68 S103 John Smith S104 IAI 65 S103 John Smith S106 PR2 43 S103 John Smith S107 PR1 76 S103 John Smith S107 PR2 60 S103 John Smith S107 IAI 35 S104 Mary Jones S103 DBS 72 S104 Mary Jones S103 IAI 58 S104 Mary Jones S104 PR1 68 S104 Mary Jones S104 IAI 65 S104 Mary Jones S106 PR2 43
SELECT ... FROM Student, Grade WHERE...
ID First Last ID Code Mark S103 John Smith S103 DBS 72 S103 John Smith S103 IAI 58 S104 Mary Jones S104 PR1 68 S104 Mary Jones S104 IAI 65 S106 Mark Jones S106 PR2 43 S107 John Brown S107 PR1 76 S107 John Brown S107 PR2 60
SELECT ... FROM Student, Grade WHERE (Student.ID = Grade.ID) AND (Mark >= 40)
First Last Mark John Smith 72 John Smith 58 Mary Jones 68 Mary Jones 65 Mark Jones 43 John Brown 76 John Brown 60
SELECT First, Last, Mark FROM Student, Grade WHERE (Student.ID = Grade.ID) AND (Mark >= 40)
ID First Last ID Code Mark Code Title
S103 John Smith S103 DBS 72 DBS Database Systems S103 John Smith S103 IAI 58 IAI Intro to AI S104 Mary Jones S104 PR1 68 PR1 Programming 1 S104 Mary Jones S104 IAI 65 IAI Intro to AI S106 Mark Jones S106 PR2 43 PR2 Programming 2 S107 John Brown S107 PR1 76 PR1 Programming 1 S107 John Brown S107 PR2 60 PR2 Programming 2 S107 John Brown S107 IAI 35 IAI Intro to AI
Student Grade^ Course
Student.ID = Grade.ID Course.Code = Grade.Code
Enrolment
ID Code
123 DBS 124 PRG 124 DBS 126 PRG
Student
ID Name
123 John 124 Mary 125 Mark 126 Jane ID^ Name
123 John 124 Mary 124 Mary 126 Jane
Code DBS PRG DBS PRG