Code Example
CREATE TABLE students (id INTEGER PRIMARY KEY, name TEXT);
CREATE TABLE courses (student_id INTEGER, course TEXT);
INSERT INTO students VALUES (1, 'Mayur'), (2, 'Priya');
INSERT INTO courses VALUES (1, 'Python'), (1, 'SQL'), (2, 'JavaScript');
SELECT students.name, courses.course
FROM students
JOIN courses ON students.id = courses.student_id
ORDER BY students.name;
Expected Output
Mayur | Python
Mayur | SQL
Priya | JavaScript
Practice Steps
- Open the SQL editor and paste the query.
- Run it to create tables, insert rows, and print joined results.
- Add another student or filter by course name.