title: Insert into table some values which are selected from other table
body: <p>I have my database structure like this :: </p>
  
  <p>Database structure :: </p>
  
  <ul>
  <li><code>ATT_table- ActID(PK), assignedtoID(FK), assignedbyID(FK), Env_ID(FK), Product_ID(FK), project_ID(FK), Status</code></li>
  <li><code>Product_table - Product_ID(PK), Product_name</code></li>
  <li><code>Project_Table- Project_ID(PK), Project_Name</code></li>
  <li><code>Environment_Table- Env_ID(PK), Env_Name</code></li>
  <li><code>Employee_Table- Employee_ID(PK), Name</code></li>
  <li><code>Employee_Product_projectMapping_Table -Emp_ID(FK), Project_ID(FK), Product_ID(FK)</code></li>
  <li><code>Product_EnvMapping_Table - Product_ID(FK), Env_ID(FK)</code></li>
  </ul>
  
  <p>I want to insert values in <code>ATT_Table</code>. Now in that table I have some columns like <code>assignedtoID</code>, <code>assignedbyID</code>, <code>envID</code>, <code>ProductID</code>, <code>project_ID</code> which are FK in this table but primary key in other tables they are simply numbers). </p>
  
  <p>Now when I am inputting data from the user I am taking that in form of string like a user enters <code>Name</code> (<code>Employee_Table</code>), <code>product_Name</code> (<code>Product_table</code>) and not ID directly. So I want to first let the user enter the name (of <code>Employee</code> or <code>product</code> or <code>Project</code> or <code>Env</code>) and then value of its primary key (<code>Emp_ID, product_ID, project_ID, Env_ID</code>) are picked up and then they are inserted into <code>ATT_table</code> in place of <code>assignedtoID, assignedbyID, envID, ProductID, project_ID</code>. </p>
  
  <p>Please note that <code>assignedtoID, assignedbyID</code> are referenced from <code>Emp_ID</code> in <code>Employee_Table</code>. </p>
  
  <p>How to do this ? I have got something like this but its not working :: </p>
  
  <pre><code>INSERT INTO ATT_TABLE(Assigned_To_ID,Assigned_By_ID,Env_ID,Product_ID,Project_ID) 
  VALUES (A, B, Env_Table.Env_ID, Product_Table.Product_ID, Project_Table.Project_ID)
  SELECT Employee_Table.Emp_ID AS A,Employee_Table.Emp_ID AS B, Env_Table.Env_ID, Project_Table.Project_ID, Product_Table.Product_ID
  FROM Employee_Table, Env_Table, Product_Table, Project_Table
  WHERE Employee_Table.F_Name= "Shantanu" or Employee_Table.F_Name= "Kapil" or Env_Table.Env_Name= "SAT11A" or Product_Table.Product_Name = "ABC" or Project_Table.Project_Name = "Project1";  
  </code></pre>