title: #1305 - FUNCTION does not exist - nested loops
body: <p>So, I'm getting an error about a function not being defined. It happens every time I try to use my counter variables to refer to specific entries in tables. I don't get it.</p>
  
  <p>To be more clear, I was advised that in order to use loops with mysql I had to make a 'procedure' which I have done. the count and ingredientcount variables are references to the row being examined in the tables tDrinks and tUniqueingredients.  </p>
  
  <p>I am trying to generate a foreign key reference for the drink id from tDrinks in the table tDrinkMix. I want there to be an entry of the drink id for each instance of a unique ingredient in the drink.  There are 16.5k drinks and 2.2k unique ingredients. </p>
  
  <p>Right now it dies on SELECT id(count) FROM tDrinks. If I remove the (count) there it dies next on WHERE d_shopping(count).</p>
  
  <p>The error thrown is #1305 and it says that the function DrinksDB.id is not defined</p>
  
  <pre><code>DROP PROCEDURE `test`//
  CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
  BEGIN
   DECLARE count INT DEFAULT 0;
   DECLARE ingredientcount INT DEFAULT 0;
   WHILE count &lt; 16532 DO
      WHILE ingredientcount &lt; 2202 DO
        INSERT INTO tDrinkMix(count)
                   SELECT id(count) FROM tDrinks
                   WHERE d_shopping(count)
                    LIKE CONCAT('%',tUniqueingredients.ingredient(ingredientcount),'%');
        SET ingredientcount = ingredientcount + 1;
      END WHILE;
     SET count = count + 1;
   END WHILE;
  END
  </code></pre>
  
  <p>So I'm working on refining this a bit, and I'm still not quite there. How can you tell this is my first database project? The following is getting closer I think: the procedure at least saves and looks like it might execute</p>
  
  <pre><code>delimiter //
  
  CREATE DEFINER=`root`@`localhost` PROCEDURE `test`()
  BEGIN
   DECLARE count INT DEFAULT 0;
   DECLARE ingredientcount INT DEFAULT 0;
   WHILE count &lt; 16532 DO
      WHILE ingredientcount &lt; 2202 DO
        INSERT INTO tDrinkMix(drink_id)
  
                  SELECT id
                  FROM tDrinks
                  WHERE id = count
  
                  and
  
                  d_shopping
  
                  LIKE 
                  (SELECT CONCAT (ingredient,'%') FROM tUniqueingredients WHERE id = ingredientcount);
  
        SET ingredientcount = ingredientcount + 1;
      END WHILE;
     SET count = count + 1;
   END WHILE;
  END//
  </code></pre>