join in sql
student table
student_id===================>primary key
======================================================================================
school table
school_id===================>primary key
student_id=================>foreign key
===============================================================================
marks table
enroll_id===================>primary key
school_id===================>foreign key
=========================================================================================
SELECT s.student_fname, s.student_mname, s.student_lname, sc.school_name, sc.school_level,m.marks, m.percentage, m.grade
FROM public.student s cross join school sc cross join marks m
SELECT s.student_fname, s.student_mname, s.student_lname, sc.school_name, sc.school_level,m.marks, m.percentage, m.grade
FROM public.student s inner join school sc on (s.student_id=sc.student_id)
inner join marks m on (sc.school_id=m.school_id)
SELECT s.student_fname, s.student_mname, s.student_lname, sc.school_name, sc.school_level,m.marks, m.percentage, m.grade
FROM public.student s join school sc on (s.student_id=sc.student_id)
join marks m on (sc.school_id=m.school_id)
SELECT s.student_fname, s.student_mname, s.student_lname, sc.school_name, sc.school_level,m.marks, m.percentage, m.grade
FROM public.student s right join school sc on (s.student_id=sc.student_id)
right join marks m on (sc.school_id=m.school_id)
SELECT s.student_fname, s.student_mname, s.student_lname, sc.school_name, sc.school_level,m.marks, m.percentage, m.grade
FROM public.student s left join school sc on (s.student_id=sc.student_id)
left join marks m on (sc.school_id=m.school_id)
SELECT s.student_fname, s.student_mname, s.student_lname, sc.school_name, sc.school_level,m.marks, m.percentage, m.grade
FROM public.student s, school sc ,marks m where (s.student_id=sc.student_id and sc.school_id=m.school_id)
No comments:
Post a Comment