样本结果:
我想知道是否有可能将性别视为男性而不是2。 它只显示使用多选答案时的答案编号,如下拉列表等。
我希望有人可以指出正确的方向,谢谢你的帮助。
答案 0 :(得分:0)
我猜这是Moodle的旧版本?
您可以使用类似的内容来替换数字:
SELECT u.id,
u.username,
/* any other user fields you need */
d.user_profile_Gender,
d.user_profile_AgeGroup,
d.user_profile_JobTitle,
d.user_profile_Department
FROM mdl_user u
LEFT JOIN (
SELECT d.userid,
MAX(CASE
WHEN f.shortname = 'Gender' AND d.data = '1' THEN 'Male'
WHEN f.shortname = 'Gender' AND d.data = '2' THEN 'Female'
ELSE null
END) AS user_profile_Gender,
MAX(CASE
WHEN f.shortname = 'AgeGroup' AND d.data = '1' THEN 'xxx'
WHEN f.shortname = 'AgeGroup' AND d.data = '2' THEN 'yyy'
ELSE null
END) AS user_profile_AgeGroup,
MAX(CASE WHEN f.shortname = 'JobTitle' THEN d.data ELSE null END) AS user_profile_JobTitle,
MAX(CASE WHEN f.shortname = 'Department' THEN d.data ELSE null END) AS user_profile_Department
FROM mdl_user_info_data d
JOIN mdl_user_info_field f ON f.id = d.fieldid
AND f.shortname IN ('Gender', 'AgeGroup', 'JobTitle', 'Department')
GROUP BY d.userid
) d ON d.userid = u.id