title: Why the value is constant?
body: <p>I would like to make a procedure which updates birth date, basing on personal identity number and everything works well apart from one thing. PID is taken only once and consequently the result is the same for all 200 records. How should I change this?</p>
  
  <p>For example: PID of the first value is 30052766293, so birth_date = 1930-05-27,but for left PIDs result (date) is the same</p>
  
  <pre><code>CREATE PROCEDURE proc()
  BEGIN
      DECLARE s INT DEFAULT 0;
      abc:LOOP
      UPDATE people
        SET birth_date = (SELECT str_to_date(CONCAT('19',substring(PID,1,2),
                            substring(PID,3,2),
                            substring(PID,5,2)
                           )
                     , '%Y %m %d') FROM workers LIMIT 1);
        SET s = s+1;
        IF s&gt;=200 
        THEN LEAVE abc; 
        END IF ;
        END LOOP;
        END $$
  </code></pre>
  
  <p>EDIT: people and workers are separate tables and both have the same column PID</p>