title: Why am i getting ERROR 1064 (42000) mysql error on procedure?
body: <p>What's wrong with my mysql 5.5 procedure?
  I'm trying to create it via mysql client command terminal on linux.</p>
  
  <pre><code>    DELIMITER //
  CREATE procedure merge()
  BEGIN
  
    DECLARE old_outlet_id INT(10);
    DECLARE new_outlet_id INT(10);
    DECLARE gpid VARCHAR(255);
    DECLARE v_finished INTEGER DEFAULT 0;
    DEClARE cur CURSOR FOR select distinct google_place_id from service_providers_outlets group by google_place_id having count(google_place_id) &gt; 1;
    DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_finished = 1;
  
    OPEN cur;
  
  
  getC: LOOP
  
   FETCH cur INTO gpid;
  
   IF v_finished = 1 THEN 
   LEAVE getC;
   END IF;
  
       SET old_outlet_id = (select id from service_providers_outlets o where google_place_id = gpid order by created_on limit 1);
       SET new_outlet_id = (select id from service_providers_outlets o where google_place_id = gpid order by created_on desc limit 1); 
  
       select concat('old_outlet_id', old_outlet_id);
       select concat('new_outlet_id', new_outlet_id);
  
       if old_outlet_id != new_outlet_id then
           update reviews_completed set outlet_id = new_outlet_id where outlet_id = old_outlet_id;
           update service_providers_offers_outlet_link set outlet_id = new_outlet_id where outlet_id = old_outlet_id;
           update service_providers_offers_redeemed set outlet_id = new_outlet_id where outlet_id = old_outlet_id;
           update reviews_questions_outlet_link set outlet_id = new_outlet_id where outlet_id = old_outlet_id;
           delete from dashboard_users_outlet_link where outlet_id = old_outlet_id;
           delete from service_providers_outlets where id = old_outlet_id;
       end if;
  
   END LOOP getC;
  
   CLOSE cur;
  
  END //
  DELIMITER ;
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <blockquote>
    <p>ERROR 1064 (42000): 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 'o where google_place_id = '' order by created_on
    limit 1); ew_outlet_id = (selec' at line 22 mysql> DELIMITER ;</p>
  </blockquote>