title: Get AutoIncrement ID and insert into Foreign Key Table
body: <p>I have 3 tables <code>User</code>, <code>Profile</code> and <code>ProfilePicture</code>. <code>Profile</code> and <code>ProfilePicture</code> have a foreign key relation with <code>User</code> table. What I want to do here is whenever I insert data into the <code>User</code> table through web application their <code>AutoGeneratedID</code> get and inserted into <code>Profile</code> and <code>ProfilePicture</code> tables.</p>
  
  <pre><code>CREATE TABLE User 
  (
      UserId INT(11) NOT NULL AUTO_INCREMENT, 
      Username VARCHAR(45) NOT NULL, 
      Password VARCHAR(50) NOT NULL,
      PRIMARY KEY (`UserId`), 
      UNIQUE INDEX `UserIdId_UNIQUE` (`UserId` ASC)
  ); 
  
  CREATE TABLE Profile 
  ( 
      UserId INT(11) NOT NULL, 
      Firstname VARCHAR(50) NULL, 
      Lastname VARCHAR(50) NULL,
      FOREIGN KEY (UserId) REFERENCES User (UserId) 
  )
  
  CREATE TABLE ProfilePicture 
  ( 
      UserId INT(11) NOT NULL, 
      Picture image NULL, 
      insertdate date NULL,
  
      FOREIGN KEY (UserId) REFERENCES User (UserId) 
  )
  </code></pre>
  
  <p>I know I have to use a trigger but I don't understand how to do this.</p>