select cc.userid,cc.course,cm.instance,cc.timecompleted from mdl_course_completions cc,mdl_course_modules cm where cc.timestarted is not NULL and cc.timestarted != '0' and cm.course in (select id from mdl_course where idnumber between '100' and '300') and cc.course=cm.course and cm.module=(select id from mdl_modules where name='quiz') order by cc.course
select id,email from tbl_course_completion_email where userid='931' and courseid='3' and quizid='5'
select id,email from tbl_course_completion_email where userid='729' and courseid='3' and quizid='5'
select id,email from tbl_course_completion_email where userid='1217' and courseid='3' and quizid='5'
select id,email from tbl_course_completion_email where userid='931' and courseid='4' and quizid='6'
select id,email from tbl_course_completion_email where userid='1217' and courseid='4' and quizid='6'
select id,email from tbl_course_completion_email where userid='776' and courseid='4' and quizid='6'
select id,email from tbl_course_completion_email where userid='1217' and courseid='5' and quizid='7'
select id,email from tbl_course_completion_email where userid='1217' and courseid='6' and quizid='8'
select id,email from tbl_course_completion_email where userid='1217' and courseid='7' and quizid='14'