-
sacwebmaster
-
-
Offline
-
Junior Boarder
-
-
Posts: 24
-
Thank you received: 0
-
-
|
This is the script that we use. It produces a report thats almost the same as the DTREgister CSV report.
The constructs The GROUP_CONCAT(IF(m.field_id = 13, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(m.value AS UNSIGNED)+1),'|',-1),NULL)) AS Class, are used to return values from select lists or radio buttons.
You'll need to poke around in the #_dtregister_fields table to find your field ids.
The full code is below: (SELECT TRIM(e.title) AS Tournament, u.userId AS UserID, u.type AS RegType, IF(u.memtot,"","") AS GroupSize, m.member_id AS MemberID, IF(p.fee,"","") AS Fee, IF(p.paid_amount,"","") AS Paid, IF(p.payment_method,"","") AS PayType,
GROUP_CONCAT(IF(m.field_id = 2, m.value, NULL)) AS FirstName,
GROUP_CONCAT(IF(m.field_id = 3, m.value, NULL)) AS LastName,
GROUP_CONCAT(IF(m.field_id = 10, m.value, NULL)) AS Email,
GROUP_CONCAT(IF(m.field_id = 11, m.value, NULL)) AS Phone,
GROUP_CONCAT(IF(m.field_id = 13, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(m.value AS UNSIGNED)+1),'|',-1),NULL)) AS Class,
GROUP_CONCAT(IF(m.field_id = 14, m.value, NULL)) AS YearofBirth,
GROUP_CONCAT(IF(m.field_id BETWEEN 15 AND 18, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(m.value AS UNSIGNED)+1),'|',-1),NULL)) AS Category,
GROUP_CONCAT(IF(m.field_id = 19, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(m.value AS UNSIGNED)+1),'|',-1),NULL)) AS Division,
GROUP_CONCAT(IF(m.field_id = 20, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(m.value AS UNSIGNED)+1),'|',-1), NULL)) AS Membership,
GROUP_CONCAT(IF(m.field_id BETWEEN 24 AND 25, m.value,NULL)) AS College,
GROUP_CONCAT(IF(m.field_id = 8, m.value, NULL)) AS ZipCode,
u.register_date AS RegDate,
u.confirmNum AS Confirm#
FROM cal_dtregister_user u
LEFT JOIN cal_dtregister_group_member g ON g.groupUserId = u.userId
INNER JOIN cal_dtregister_member_field_values m ON m.member_id = g.groupMemberId
INNER JOIN cal_dtregister_fee p ON p.user_id = u.userId
INNER JOIN cal_dtregister_group_event e ON e.slabId = u.eventID
INNER JOIN cal_dtregister_fields f ON m.field_id = f.id
WHERE u.eventID = 4
GROUP BY m.member_id)
UNION
(Select TRIM(e.title) AS Tournament, u.userId AS UserID, u.type AS RegType, u.memtot AS GroupSize, IF(u.type, "", "") AS MemberID, p.fee AS Fee, p.paid_amount AS Paid,
CASE
WHEN p.payment_method = 2 THEN "Mail"
WHEN p.payment_method = 3 THEN "Phone"
WHEN p.payment_method = 4 THEN "On Site"
ELSE p.payment_method
END AS PayType,
GROUP_CONCAT(IF(v.field_id = 2, v.value, NULL)) AS FirstName,
GROUP_CONCAT(IF(v.field_id = 3, v.value, NULL)) AS LastName,
GROUP_CONCAT(IF(v.field_id = 10, v.value, NULL)) AS Email,
GROUP_CONCAT(IF(v.field_id = 11, v.value, NULL)) AS Phone,
GROUP_CONCAT(IF(v.field_id = 13, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(v.value AS UNSIGNED)+1),'|',-1),NULL)) AS Class,
GROUP_CONCAT(IF(v.field_id = 14, v.value, NULL)) AS YearofBirth,
GROUP_CONCAT(IF(v.field_id BETWEEN 15 AND 18, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(v.value AS UNSIGNED)+1),'|',-1),NULL)) AS Category,
GROUP_CONCAT(IF(v.field_id = 19, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(v.value AS UNSIGNED)+1),'|',-1),NULL)) AS Division,
GROUP_CONCAT(IF(v.field_id = 20, SUBSTRING_INDEX(SUBSTRING_INDEX(f.values, '|', CAST(v.value AS UNSIGNED)+1),'|',-1), NULL)) AS Membership,
GROUP_CONCAT(IF(v.field_id BETWEEN 24 AND 25, v.value,NULL)) AS College,
GROUP_CONCAT(IF(v.field_id = 8, v.value, NULL)) AS ZipCode,
u.register_date AS RegDate,
u.confirmNum AS Confirm#
FROM cal_dtregister_user u
INNER JOIN cal_dtregister_user_field_values v ON v.user_id = u.userId
INNER JOIN cal_dtregister_fee p ON p.user_id = u.userId
INNER JOIN cal_dtregister_group_event e ON e.slabId = u.eventID
INNER JOIN cal_dtregister_fields f ON v.field_id = f.id
WHERE u.eventID = 4
GROUP BY u.userId)
ORDER BY RegType DESC, UserID, GroupSize DESC, FirstName
|