title: Stored function in MYSQL
body: <p>If I have a TABLE named MyTable which has columns say C1(type date) and C2 (type character) I want to create a stored function that takes an input and the input should always belong to C1, and the output of the stored function should be the corresponding element in C2. I have tried to do it using the 'select' statement followed by 'where' clause inside the stored function but was not able to achieve it. Is there any other way to accomplish this task.</p>
  
  <pre><code>DELIMITER $$ 
  CREATE FUNCTION `MyFunction` 
    (`Date` datetime) 
    RETURNS char(10)
  BEGIN 
    DECLARE MyVariable char(10)
  SELECT MyVariable = `C2`
  FROM MyTable
  WHERE `Date` = `C1`; RETURN MyVariable;
  END$$
  DELIMITER ;
  </code></pre>
  
  <p>But this keeps giving me ERROR CODE: 1064</p>