I am using a MySQL stored function where I have created a function and I have passed column name as a parameter to this function. Suppose
CREATE DEFINER=`ro
I am not sure what you are trying to ask. But here is a solution using Prepared Statements:
SET @selectStatement = CONCAT('Select ', columnName1,' from tab1 where id = 1'); -- Build Select statement like this
PREPARE stmt FROM @selectStatement; -- parse and prepare insert statement from the above string
EXECUTE stmt; -- execute statement
DEALLOCATE PREPARE stmt; -- release the statement memory.
I don't know the complete scenario, but this may be avoided by changing some design.