title: MySQL temp table cursor
body: <p>I am writing MySQL stored procedure and I am having problems iterating trough temporary table rows with the cursor. I assume that the data is being selected before the table is populated, but not sure. Here are basic steps in my procedure:</p>
  
  <pre><code>- DECLARE articles_cursor CURSOR FOR SELECT DISTINCT title FROM FoundIn;
  - CREATE TEMPORARY TABLE IF NOT EXISTS FoundIn ( ... );
  - Populate the table ...
  - Open the cursor and try to fetch data
  </code></pre>
  
  <p>And every time i get NOT FOUND in my cursor. If the problem is that cursor is declared before the table, is there a way to work around it? Also, I need distinct values to iterate trough, so I suppose a WHILE loop is not an option.</p>