First of all, I would suggest changing the design of the tables. Instead of storing multiple values in column p1...p5, store them as rows in a separate table. This would make the data handling really much easier.
Now what comes to the query, even though you said that you have the column name in PNAME I would believe that it would be easier to transform the columns to rows and then find the maximum.
A brute force solution would be to use union. Consider the following:
SELECT a.id, MAX(a.val)
FROM (
SELECT sd.id, sd.p1 as val FROM sdata sd UNION ALL
SELECT sd.id, sd.p2 as val FROM sdata sd UNION ALL
SELECT sd.id, sd.p3 as val FROM sdata sd UNION ALL
SELECT sd.id, sd.p4 as val FROM sdata sd UNION ALL
SELECT sd.id, sd.p5 as val FROM sdata sd) AS a
GROUP BY a.id