From: Gavin Towey Date: March 15 2010 6:13pm Subject: RE: udf return column name not value List-Archive: http://lists.mysql.com/mysql/220953 Message-Id: <21A67E2153E64D48ACBD190732CB859169EE25@site1-mailbox1.pmgi.local> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable You'll have to do something like this: SET @sql :=3D CONCAT('select ',columnname,' into retval from user where ID= =3D',id); PREPARE mySt FROM @sql; EXECUTE mySt; -----Original Message----- From: chamila gayan [mailto:cgchamila@stripped] Sent: Monday, March 15, 2010 12:58 AM To: mysql@stripped Subject: udf return column name not value CREATE FUNCTION getcolumnvalue(id int,columnname varchar(30)) RETURNS varchar(50) DETERMINISTIC READS SQL DATA begin declare retval varchar(50); return retval; end; I want get value of related column but it return column name. ex:- ('tom' what I want but it return 'name') plz tell what the wrong of this thank you This message contains confidential information and is intended only for the= individual named. If you are not the named addressee, you are notified th= at reviewing, disseminating, disclosing, copying or distributing this e-mai= l is strictly prohibited. Please notify the sender immediately by e-mail i= f you have received this e-mail by mistake and delete this e-mail from your= system. E-mail transmission cannot be guaranteed to be secure or error-fre= e as information could be intercepted, corrupted, lost, destroyed, arrive l= ate or incomplete, or contain viruses. The sender therefore does not accept= liability for any loss or damage caused by viruses or errors or omissions = in the contents of this message, which arise as a result of e-mail transmis= sion. [FriendFinder Networks, Inc., 220 Humbolt court, Sunnyvale, CA 94089,= USA, FriendFinder.com