SQL Query: Column Name as Value
You are right about UNION or UNION ALL. Due to the field column, the legs in the UNION will be disjoint:

SELECT FieldA, field1 as value, 'field1' as field
FROM T
UNION ALL
SELECT FieldA, field2 as value, 'field2' as field
FROM T


I don't think MySQL as of latest version yet supports LATERAL, but I may be mistaken so in case it does, it will be slightly more efficient to do something like:

SELECT x.FieldA, x.value, x.field
FROM T
LATERAL JOIN (
    values (T.FieldA, field1, 'field1')
         , (T.FieldA, field2, 'field2')
) x (FieldA, value, field);


You may have to do:

LATERAL JOIN (
    SELECT T.FieldA, field1 as value, 'field1' as field
    UNION ALL
    SELECT T.FieldA, field2 as value, 'field2' as field
) x;