I\'m learning stored procedures/functions/triggers in MySQL this morning and I\'m having some problems trying to use variable table and column names in queries.
Use User/Global Vars for this along with PREPARE & EXECUTE:
SET @columnName='myColumn';
SET @tableName='myTable';
SET @whatEver='requiredValue';
SET @query=CONCAT('SELECT ', @columnName, ' FROM ', @tableName, ' WHERE Column=', @whatEver);
PREPARE QUERY FROM @QUERY;
EXECUTE QUERY;
Haven't tested this EXACT code but something along these lines will work. Also has to be inside a Procedure, cannot be used with a function or trigger, if anyone has a soloution for that then please post.