title: PostgreSQL: Sub-select inside insert
body: <p>I have a table called <code>map_tags</code>:</p>
  
  <pre><code>map_id | map_license | map_desc
  </code></pre>
  
  <p>And another table (<code>widgets</code>) whose records contains a foreign key reference (1 to 1) to a <code>map_tags</code> record:</p>
  
  <pre><code>widget_id | map_id | widget_name
  </code></pre>
  
  <p>Given the constraint that all <code>map_license</code>s are unique (however are not set up as keys on <code>map_tags</code>), then if I have a <code>map_license</code> and a <code>widget_name</code>, I'd like to perform an insert on <code>widgets</code> all inside of the same SQL statement:</p>
  
  <pre><code>INSERT INTO
      widgets w
  (
      map_id,
      widget_name
  )
  VALUES (
      (
          SELECT
              mt.map_id
          FROM
              map_tags mt
          WHERE
              // This should work and return a single record because map_license is unique
              mt.map_license = '12345'
      ),
      'Bupo'
  )
  </code></pre>
  
  <p>I <em>believe</em> I'm on the right track but know right off the bat that this is incorrect SQL for Postgres. Does anybody know the proper way to achieve such a single query?</p>