PHP Snippet 1:
select m.mbr_name
from Members m
where Exists ( select 1 from Course_Registration cr
join Course_Comments cm on cr.crr_cor_id = cm.crm_reference_id
where cr.crr_mbr_id = m.mbr_id
And cr.crr_status = "completed" AND cr.crr_ts >= "2021-03-07 00:00:00" AND cr.crr_ts < "2022-03-17 00:00:00"
AND cr.crm_confirmation = "accept";
);
PHP Snippet 2:
SELECT
members.mbr_name
FROM
(
SELECT DISTINCT
crm_reference_id
FROM
course_comments
WHERE
crm_confirmation = 'accept'
) accepted_comments
INNER JOIN
(
SELECT DISTINCT
crr_mbr_id,
crr_cor_id
FROM
course_registration
WHERE
crr_status = 'completed'
AND
crr_ts BETWEEN '2021-03-07 00:00:00' AND '2022-03-17 00:00:00'
) completed_courses
ON
accepted_comments.crm_reference_id = completed_courses.crr_cor_id
INNER JOIN
members
ON
members.mbr_id = completed_courses.crr_mbr_id
PHP Snippet 3:
select
m.mbr_name,
m.mbr_id
from
( select distinct
cr.crr_mbr_id
from
course_registration cr
JOIN course_comments cc
ON cr.crr_cor_id = cc.crm_reference_id
AND cc.crm_confirmation = 'accept'
WHERE
cr.crr_status = 'completed'
AND cr.crr_ts >= '2021-03-07'
AND cr.crr_ts < '2022-03-17' ) PQ
JOIN members m
ON PQ.crr_mbr_id = m.mbr_id
PHP Snippet 4:
SELECT *
FROM members M
INNER JOIN course_registration CR
ON CR.crr_mbr_id = M.mbr_id
AND CR.crr_status = 'completed'
AND CR.crr_ts BETWEEN '2021-03-07 00:00:00' AND '2022-03-17 00:00:00'
WHERE EXISTS(
SELECT * FROM course_comments CC
WHERE CC.crm_confirmation = 'accept'
AND CC.crm_reference_id = CR.crr_cor_id
)
ORDER BY M.mbr_id;
PHP Snippet 5:
select mbr.mbr_name from
(
select * from course_registration AS udt
INNER JOIN course_comments AS dot ON udt.crr_cor_id = dot.crm_reference_id
where dot.crm_confirmation = "accept" AND udt.crr_status = "completed" AND udt.crr_ts >= "2021-03-07 00:00:00" AND udt.crr_ts < "2022-03-17 00:00:00"
)x
INNER JOIN members mbr on mbr.mbr_id = x.crr_mbr_id