sql - Trouble With Query Utilizing Views -


i working on database student organization. 1 feature of database record student attendance events. if student not attend event, lack of attendance not entered. in order student attend event must enrolled. following tables utilized process:

student student_id int (pk), student_m, first_name, last_name, gender, email, phone, degree, grad_term, grad_year,  student_enrollment enrollment_id (pk), student_id (fk), term, year, status,  student_attend att_id (pk), enrollment_id (fk), event_id (fk),  event event_id (pk), event_name, location, term, year, date, time, description, cost, dress_code, require, 

my goal write query display lack of attendance. in query trying pull student's name , email , list of events did not attend required (where event.require = 'y'). have tried multiple ways of writing this, many of include numerous views, no luck. if has creative thoughts here help!

thanks

you need cross join between students , events possible combinations of two. filter required events there no link between student , event.

select * student s cross join event e e.require = 1   , not exists    (     select * student_attend sa       inner join student_enrollment se       on se.enrollment_id = sa.enrollment_id     sa.event_id = e.event_id       , se.student_id = s.student_id   ) 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -