gavinbaumanis
12/21/2022, 9:43 AMMark Berning
12/21/2022, 10:54 AMLukas
12/21/2022, 11:34 AMSELECT
v.survey_id,
concat(
(CASE WHEN internalName='PvFf9Bzd_response' THEN questionText ELSE '' END),
(CASE WHEN internalName='yW3AEXOT_response' THEN questionText ELSE '' END),
(CASE WHEN internalName='IES35zCj_response' THEN questionText ELSE '' END),
(CASE WHEN internalName='IES35zCj_response_reason' THEN questionText ELSE '' END)
) AS question,
v.IES35zCj_response_reason
from vxml_xxxxxx v inner join ws_question ws on v.id = ws.id
where ws.internalName in (
select COLUMN_NAME
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = "vxml_xxxxxx" AND COLUMN_NAME like "%response%")
;
produces output like so:Lukas
12/21/2022, 11:35 AMTim
12/21/2022, 2:30 PMPIVOT, but it looks like mysql doesn't have that...Michael Schmidt
12/21/2022, 4:28 PMgavinbaumanis
12/22/2022, 12:58 AMgavinbaumanis
12/22/2022, 1:15 AMid, survey_id, PvFf9Bzd_response, yW3AEXOT_response, IES35zCj_response, IES35zCj_response_reason
to
id, survey_id, questionText_for_PvFf9Bzd_response, PvFf9Bzd_response, questionText_for_yW3AEXOT_response, yW3AEXOT_response, questionText_for_IES35zCj_response, IES35zCj_response, questionText_for_IES35zCj_response_reason, IES35zCj_response_reason
or a little more clearly;
id, survey_id, ..., Q1_TEXT, Q1_answer, Q2_TEXT, Q2_answer
Where Q1_TEXT / Q2_TEXT / etc - are the new columns I need to add.gavinbaumanis
12/22/2022, 1:17 AM