I have a class registration form. The database has a semester table, class table, student table and registration table.
I want a query to return a list of students that are registered for a class in an active semester. I have the query, but it returns each student twice. I can use DISTINCT, but I feel that using it is necessary because I have a poorly formed query. Or, maybe I do need to use DISTINCT??
Can someone please take a look and suggest how I can improve my results?
SELECT c.student_id, c.student_last_name ||', '|| c.student_first_name As "student_name", c.student_esis_id AS "esis_id", FROM ( summer_scholars_semester a INNER JOIN summer_scholars_class b ON a.semester_id = b.semester_id ), ( summer_scholars_registration r INNER JOIN summer_scholars_student c ON c.student_id = r.student_id ) WHERE b.class_id = r.class_id AND a.active AND a.semester_deleted_date IS NULL AND c.student_deleted_date IS NULL ORDER BY "student_name"