I have a large dataset that contains one line per person, and 25 criteria columns that may or may not be populated, like this sample:
SELECT * FROM Criteria_Input; ╔══════════╦═══════════╦═══════════╦═══════════╦═══════════╦═══════════╦═══════════╗ ║ Name ║ Criteria1 ║ Criteria2 ║ Criteria3 ║ Criteria4 ║ Criteria5 ║ Criteria6 ║ ╠══════════╬═══════════╬═══════════╬═══════════╬═══════════╬═══════════╬═══════════╣ ║ Michael ║ ║ Yes ║ ║ ║ Yes ║ ║ ║ Brant ║ ║ ║ ║ ║ ║ Yes ║ ║ Mary ║ Yes ║ ║ ║ Yes ║ ║ ║ ║ John ║ ║ ║ ║ ║ Yes ║ ║ ║ Connie ║ ║ ║ Yes ║ Yes ║ ║ ║ ╚══════════╩═══════════╩═══════════╩═══════════╩═══════════╩═══════════╩═══════════╝ I need to convert this data into rows like this:
SELECT * FROM Criteria_Final; ╔═════════╦═══════════╗ ║ Name ║ Criteria ║ ╠═════════╬═══════════╣ ║ Michael ║ Criteria2 ║ ║ Michael ║ Criteria5 ║ ║ Brant ║ Criteria6 ║ ║ Mary ║ Criteria1 ║ ║ Mary ║ Criteria4 ║ ║ John ║ Criteria5 ║ ║ Connie ║ Criteria3 ║ ║ Connie ║ Criteria4 ║ ╚═════════╩═══════════╝ or even better, something this:
SELECT * FROM Criteria_Final; ╔═════════╦══════════╗ ║ Name ║ Criteria ║ ╠═════════╬══════════╣ ║ Michael ║ 2 ║ ║ Michael ║ 5 ║ ║ Brant ║ 6 ║ ║ Mary ║ 1 ║ ║ Mary ║ 4 ║ ║ John ║ 5 ║ ║ Connie ║ 3 ║ ║ Connie ║ 4 ║ ╚═════════╩══════════╝ Is this kind of data transformation possible in MySQL? The reason I need to do this kind of conversion is that I will join the resulting table with another table on the criteria number.