Hello,
I built this query a while back and now I need to make some changes and I'm a bit stumped.
The old query looked up all of the available units a student could take as well as looking up the status and scores of the units the student had taken. All the schools took the same units.
Here's the old query:
---------------------------------------------------------------
SELECT unit_control.*, student_unit_history.*
FROM unit_control
LEFT JOIN student_unit_history
ON unit_control.uc_unit_code = student_unit_history.unit_id
AND student_unit_history.student_id = '$sess_user_pass'
WHERE unit_control.uc_content_area = '$get_content_area'
AND unit_control.uc_unit_level = '$db_grade_scope'
ORDER BY unit_control.uc_unit_code
Now I need to assign units to schools so I made a lookup table, for testing I made the following query:
-----------------------------------------------------
SELECT uc_unit_code, uc_unit_name FROM unit_control, sc_unit_lookup
WHERE sc_unit_lookup.sc_id = '$school_id'
AND sc_unit_lookup.u_id = unit_control.uc_unit_code
With that in mind, how can I...
1/ Display all units assigned to a particular school
2/ Display a students score for those units if he has taken them
And do this in one query.
I feel like I'm close.
Thanks, I hope this makes sense.
Don
I built this query a while back and now I need to make some changes and I'm a bit stumped.
The old query looked up all of the available units a student could take as well as looking up the status and scores of the units the student had taken. All the schools took the same units.
Here's the old query:
---------------------------------------------------------------
SELECT unit_control.*, student_unit_history.*
FROM unit_control
LEFT JOIN student_unit_history
ON unit_control.uc_unit_code = student_unit_history.unit_id
AND student_unit_history.student_id = '$sess_user_pass'
WHERE unit_control.uc_content_area = '$get_content_area'
AND unit_control.uc_unit_level = '$db_grade_scope'
ORDER BY unit_control.uc_unit_code
Now I need to assign units to schools so I made a lookup table, for testing I made the following query:
-----------------------------------------------------
SELECT uc_unit_code, uc_unit_name FROM unit_control, sc_unit_lookup
WHERE sc_unit_lookup.sc_id = '$school_id'
AND sc_unit_lookup.u_id = unit_control.uc_unit_code
With that in mind, how can I...
1/ Display all units assigned to a particular school
2/ Display a students score for those units if he has taken them
And do this in one query.
I feel like I'm close.
Thanks, I hope this makes sense.
Don