title: MySQL trigger with nested select
body: <p>I am trying to create a MySQL trigger which runs after insert on table A and am concerned with multiple rows.  Basically, when I insert into table A, I want to insert a row into table B with the every row from table C and and the inserted ID from table A.  Can someone help?</p>
  
  <p>This is the general idea -</p>
  
  <pre><code>DELIMITER |
  CREATE TRIGGER mailings_create AFTER INSERT ON mailings FOR EACH ROW
  BEGIN   
      SELECT
          customer_id,
          first_name,
          last_name,
          email
      INTO
          customer_id,
          first_name,
          last_name,
          email
      FROM
          cam_customers
      WHERE
          mail_list = 'T'
          AND email IS NOT NULL;
  
      foreach ($data as $row) {
          INSERT INTO
              mailings_messages
              (mailings_id, first_name, last_name, customer_id, email)
          VALUES
              (NEW.id, first_name, lsat_name, customer_id, email);
      }
  ...
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>Evan</p>