Q:

MySQL select unique row entries of a column as columns in a new view or table

I have a dilemma. I am using a CMS that creates a database table where the records are populated as follows:
+------------+----------------+
| field_name |  field_value   |
+------------+----------------+
| your-name  | Adam           |
| your-email | adam@email.com |
| your-name  | Ben            |
| your-email | en@email.com   |
+------------+----------------+

where field_name and field_value are column names. Also, 'your-name' and 'your-email' are are the input names of forms in a webpage.
(there are other columns but none of them have a unique row entry)
My question is, how do i create a table or view so that I can get to this from the above table?
+-----------+----------------+
| your-name |   your-email   |
+-----------+----------------+
| Adam      | Adam@email.com |
| Ben       | Ben@email.com  |
+-----------+----------------+

I have thought about creating views and joining them but I cannot seem to get it working.
Any ideas how to implement this?
Thank you!

A:

Do you have an ID in your table? If you have, you could use this:
SELECT
  MAX(CASE WHEN field_name='your-name' THEN field_value END) your_name,
  MAX(CASE WHEN field_name='your-email' THEN field_value END) your_email
FROM
  yourtable
GROUP BY
  id

Please see fiddle here.

