title: mysql insert with value, with selected data from another table
body: <p>I have a MySQL problem I can not get to solve. I have a mysql to manage a virtual user dovecot installation, that uses two tables (one for the aliases, another for the domains). </p>
  
  <p>The table aliases has these fields: domain_id(INT), source(VARCHAR), destination(VARCHAR), whereas table domains has only two fields: id (INT AUTO INC) and name (VARCHAR).</p>
  
  <p>Although I'm able to select aliases that belong to a given domain by issuing:</p>
  
  <pre><code>SELECT valias.* FROM aliases AS valias
  JOIN domains AS vdomains ON valias.domain_id=vdomains.id 
  WHERE vdomains.name = "domain_name";
  </code></pre>
  
  <p>I can not get to work to insert a new alias, specifing the domain name. something like this:</p>
  
  <pre><code>INSERT INTO valias(domain_id, source, destination) 
      VALUES (id, 'canto', 'george') 
      SELECT id FROM aliases 
      JOIN domains AS vdomains ON aliases.domain_id=vdomains.id 
      WHERE  vdomains.name =     "domain_name";
  </code></pre>
  
  <p>Does somebody know how to solve this problem?</p>