7
sql
-- View the students table
SELECT * FROM students;
-- View the days table
SELECT * FROM days;
-- View the employees table
SELECT * FROM employees;
-- CROSS JOIN example: generate all student-day pairs
SELECT students.name, days.day
FROM students
CROSS JOIN days;
-- SELF JOIN example: find each employee’s manager
SELECT employees.name AS employee, managers.name AS manager
FROM employees
LEFT JOIN employees AS managers
ON employees.manager_id = managers.id;
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.