title: Insert data from another table with a loop in mysql
body: <p>I could solve it with <code>php</code> or some other language but I am keen to learn more SQL. </p>
  
  <p>Is there a way to solve this: </p>
  
  <p>I have two tables (and I can't change the structure), one <code>content</code> with some data and the other <code>content_info</code> with some additional information. They are related that way: <code>content.id = content_info.content_id</code>.</p>
  
  <p>What I would like to do: If there is no dataset in <code>content_info</code> but in <code>content</code>, I would like to copy it over, that at the end there are the same number of datasets in both tables. I tried it that way, but unfortunately it doesn't work:</p>
  
  <pre><code>...
  BEGIN
    (SELECT id, ordering FROM content;)
    cont:LOOP
      @cid = SELECT content_id FROM content_info WHERE content_id = (id)
      IF @cid != (id) THEN
        INSERT INTO content_info SET content_id = (id), ordering = (ordering)
        ITERATE cont;
      END IF;
    END LOOP cont;
  END
  ..
  </code></pre>
  
  <p>Has someone an idea, or isn't it possible at the end? Thanks in advance!</p>