Hi to all,
i need a help
I have 2 tables namely subjects & marks.
Subjects has 2 columns namely subject_id (PK), subject_name & class_id (FK).
Marks has mark_id, student_id(FK), exam_id (FK), sub_1, sub_2, ... sub_n
here sub_1, sub_2, ... sub_n are columns in 'Marks' table but actually they are records in 'Subjects' table
I need to select the subjects by
'SELECT subject_name FROM subjects WHERE class_id = 1;'
then
'SELECT sub_1, sub_2, ... sub_n FROM marks WHERE exam_id = 1 AND student_id = 1;'
is there any way to combine these two queries like
'SELECT (SELECT subject_name FROM subjects WHERE class_id = 1) FROM marks WHERE exam_id = 1 AND student_id = 1;'
-- I knew that this query is wrong but expect the result some thing like that So that i can have the marks of a particular student.
Thanks