title: MYSQL - Stored Procedure Utilising Comma Separated String As Variable Input
body: <p>Im hoping someone will be able to help. I have created my first stored procdure (nothing fancy) however im running into an issue.</p>
  
  <p>I want to give it a string input such as 1,2,3,4,5 then it does a simple <code>SELECT * FROM [TABLE] WHERE EAN IN (VAR);</code></p>
  
  <p>So the stored proc looks like this:</p>
  
  <pre><code>-- --------------------------------------------------------------------------------
  -- Routine DDL
  -- Note: comments before and after the routine body will not be stored by the server
  -- --------------------------------------------------------------------------------
  DELIMITER $$
  
  CREATE PROCEDURE `moments`.`new_procedure`(IN var1 VARCHAR(255))
  BEGIN
  
  SELECT * FROM moments.PRODUCT WHERE EAN IN (var1);
  
  END
  </code></pre>
  
  <p>Im am trying to execute it like such:</p>
  
  <p><strong>Works</strong></p>
  
  <pre><code>call moments.new_procedure('5045318357397')
  </code></pre>
  
  <p><strong>Does Not Work</strong></p>
  
  <pre><code>call moments.new_procedure('5045318357397,5045318357427');
  </code></pre>
  
  <p>This executes but doesnt not bring back any results. Is it classing the second statement as a string so its doing this:</p>
  
  <pre><code>select * from moments.PRODUCT WHERE EAN IN ('5045318357397,5045318357427')
  </code></pre>
  
  <p>and not this:</p>
  
  <pre><code>select * from moments.PRODUCT WHERE EAN IN ('5045318357397','5045318357427')
  </code></pre>
  
  <p>How do i have to format the input in the execute query to get it to take a comma separated string as an input?</p>