sql - Linking of field data to field name between two tables -


i have 1 table name class_sub have subjects name according classes, have weekly_test table same subject's marks have entered.

my problem show subject name field name in weekly_test table reference class_sub table data fields.

if have following tables:

class     id     name subject    id    name class_subject    id    class_id    subject_id weekly_marks    id    class_subject_id    test_date    mark 

the following query work:

select s.name subject_name,        c.name class_name,        wm.test_date,        wm.mark   weekly_marks wm inner join class_subject cs on wm.class_subject_id = cs.id inner join class c on cs.class_id = c.id inner join subject s on cs.subject_id = s.id 

a bit of guess here, assuming class_subject table you're talking joining of subjects (students?) classes enrolled in.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -