How to use MySQL stored function argument to refer to column name? How can I use a function argument s to stand in for a column name in a query?  I'm using mysql 5.5.  I tried 

SELECT count_distinct(last_name)


but it returns 

ERROR 1054 (42S22): Unknown column 'last_name' in 'field list'


The function was defined as

CREATE FUNCTION count_distinct (s CHAR(20) )
RETURNS INT
READS SQL DATA
RETURN( SELECT COUNT(DISTINCT s) FROM president);


I expected it to return a value of 37 as

SELECT COUNT(DISTINCT last_name) FROM president


returns 37. 
The 'president' table is from the sampdb database from MySQL by Paul Dubois.
With thanks to Colin 't Hart this worked:

DELIMITER $
CREATE PROCEDURE showUnique( IN col CHAR(64))
BEGIN
SET @s=CONCAT('SELECT COUNT(DISTINCT ',col,') FROM president);
PREPARE stmt from @s;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END $
delimiter ;
CALL showUnique(last_name)