title: PREPARED STATEMENT in a WHILE loop
body: <p>I have a table <code>autos</code> that has a column <code>name</code>, I want to check first 5 rows in the table and if <code>name</code> value is <code>"toyota"</code>, in table <code>mytable</code> write "yes", else write "no".
  I write stored procedure, but <code>mysqli_error()</code> returns error in line, where I have <code>EXECUTE ...</code>.</p>
  
  <p>If in <code>WHEN</code> I write not <code>PREPARED STATEMENT</code>, but directly the query, the procedure works.
  Please see my code and tell me, where is it wrong?</p>
  
  <pre><code>CREATE PROCEDURE proc_auto()
  BEGIN
  
  DECLARE start INT;
  SET start = 0;
  PREPARE stmt FROM  ' SELECT name FROM autos ORDER BY id LIMIT ?,1 ';
  
  WHILE start &lt; 5 DO
  
      CASE 
          WHEN (EXECUTE stmt USING @start ) = 'toyota'
              THEN INSERT INTO mytable (log)  VALUES('yes');
          ELSE 
             INSERT INTO mytable (log)  VALUES('no');
      END CASE;
      SET start = start + 1;
  
  END WHILE;
  END;
  </code></pre>