title: How to declare a stored procedure with one input variable in MySQL?
body: <p>I have this table (named Sandbox):</p>
  
  <pre><code>+----+-----------+---------+
  | ID | statecode | country |
  +----+-----------+---------+
  |  1 | ITA       | Italy   |
  |  2 | ESP       | Spain   |
  |  3 | GER       | Germany |
  |  4 | ESP       | Espana  |
  +----+-----------+---------+
  </code></pre>
  
  <p>I am trying to create a stored procedure which gives me all the country names from one parameter (the statecode).</p>
  
  <p>For example</p>
  
  <pre><code>CALL GetCountryNameFromCode('ITA'); 
  </code></pre>
  
  <p>should return "Italy"</p>
  
  <pre><code>CALL GetCountryNameFromCode('ESP'); 
  </code></pre>
  
  <p>should return "Spain", "Espana"</p>
  
  <p>Following <a href="http://www.mysqltutorial.org/stored-procedures-parameters.aspx" rel="nofollow noreferrer">this guide</a> I wrote the following code:</p>
  
  <pre><code>DELIMITER //
  CREATE PROCEDURE GetCountryNameFromCode (IN MyStateCode varchar(3))
  BEGIN
      SELECT country
      FROM Sandbox
      WHERE statecode = MyStateCode
  END; //
  DELIMITER ;
  </code></pre>
  
  <p>but when I execute it, the phpMyAdmin gives me the following error:</p>
  
  <blockquote>
    <p>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
    near 'END' at line 6</p>
  </blockquote>
  
  <p>what's wrong with my code? 
  I am running the MySQL version 5.6.30 - Source distribution (AMPPS on MacOS)</p>
  
  <p>============================== EDIT ==============================</p>
  
  <p>Now I am running this:</p>
  
  <pre><code>DELIMITER //
  CREATE PROCEDURE GetCountryNameFromCode (IN MyStateCode varchar(3))
  BEGIN
      SELECT country
      FROM Sandbox
      WHERE statecode = MyStateCode;
  END //
  DELIMITER ;
  </code></pre>
  
  <p>which gives me the following error:</p>
  
  <blockquote>
    <p>#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
    near 'DELIMITER' at line 1</p>
  </blockquote>
  
  <p>Despite the error message the SP is been created and works perfectly.</p>