Hello experts,
I have to write a sql joining 6 tables. to retrieve classid, planname, workoutname,date,timeslot,status,staffemail and display them to a gridview.
the tables are as below
tblclass having columns classid(PK), planallocationid(FK to tblallocation), date, timeslotid(FK to tbltimeslot),status, staffid(FK to tblstaff)
tblallocation having columns planallocation(PK), planid(FK to tblplan), workoutid(FK to tblworkout)
tblplan having columns planid(PK), planname
tblworkout having columns workoutid(PK), workoutname
tblstaff having columns staffid(PK), staffemail
tbltimeslot having columns timeslotid(PK), timeslot
i came up with something like below but am getting lost with all these. Can anyone help!
SELECT a.planname, b.workoutname, c.timeslot, e.date, e.status, d.email from tblclass e
inner join tblallocation f on f.planid=a.planid, f.workoutid=b.workoutid
inner join tbltimeslot c on c.timeslotid=e.timeslotid
inner join tclstaff d on d.staffid=e.staffid