§ — — Information Management
The SELECT statement retrieves data from tables. Basic syntax:
SELECT column1, column2
FROM table_name
WHERE condition;
For example, SELECT name, program FROM Student WHERE year = 3; lists names and programs of all 3rd-year students. The WHERE clause filters rows (using =, <, >, LIKE, etc.). You can select all columns with SELECT *, but in exams it's better to list needed columns. Always test your WHERE conditions.
To query multiple tables, use JOINs. The most common is INNER JOIN, which combines rows with matching keys. Example:
SELECT s.name, c.course_name
FROM Student s
JOIN Enrollment e ON s.student_id = e.student_id
JOIN Course c ON e.course_id = c.course_id;
This lists each student with each course they are enrolled in. There are also LEFT JOIN (includes all left-table rows even if no match) and RIGHT/FULL JOIN (right or both sides). In exams, INNER JOIN is most common. Use table aliases (like s, e, c) for brevity. Ensure you join on the correct key columns.
ProReviewer — locked
Drills, code labs, and full solutions.
ProReviewer — locked
Drills, code labs, and full solutions.
ProReviewer — locked
Drills, code labs, and full solutions.
Done with this module? Track it — your progress shows on the subject list.
Up next
Lesson 6: Transactions and Concurrency Control→←Previous: Lesson 4: SQL – Data Definition and Data Manipulation