I have three tables. parent, student, student_parent'
parent
p_id
p_name
student
s_id
s_name
student_parent
s_id
p_id
I want to form a new table for a reporting functionality, in the following format.
s_id | s_name | p_name_1 | p_name_2
Since two records are created for one student such as mother and father, i want to get both the records to a single table with one s_id. Currently i have a table like this,
p_id | s_id | s_name | p_name
01 | 01 | sam | jack
02 | 01 | sam | jill
I want the table to be in the following structure.
s_id | s_name | p_name_1 | p_name_2
01 | sam | jack | jill
I have searched but could not find a proper solution.
Here is my curremt sql statement:
SELECT s.student_id, s.first_name, s.last_name, c.first_name
FROM fsms_student s, fsms_student_parent_guardian b, fsms_parent_guardian c
WHERE b.student_id = s.student_id AND b.parent_guardian_id = c.parent_guardian_id
I would be very much obliged if someone could provide me with a solution. Thank you.