title: PostgreSQL Inserting 2 relationships at once
body: <p>I have 3 tables <code>professionals</code>, <code>services</code>, and <code>feature_professional</code> I need to insert data into when inserting a <code>professional</code>. This is the sql I've tried.</p>
  
  <pre><code>WITH professionals as (INSERT INTO professionals(id, company_id, first_name) 
  VALUES (1, 1, 'peter') RETURNING *) 
  
  INSERT INTO services(id, professional_id, name) 
  VALUES (1, (select professionals.id from professionals), 'haircut'),
  
  INSERT INTO feature_professional(id, professional_id, feature_id, enabled) 
  VALUES
      (1, (select professionals.id from professionals), 1, true)
  </code></pre>
  
  <p>I've also tried different variations of this wrapping all the insert statements inside parenthesis but still no luck. The error I'm getting is a <code>syntax error</code>. </p>
  
  <pre><code>ERROR:  syntax error at or near "INSERT"
  LINE 106: INSERT INTO feature_professional
  </code></pre>
  
  <p>What is the correct syntax to accomplish this? I know that if I take out the third <code>insert</code> statement the query works. For example:</p>
  
  <pre><code>WITH professionals as (INSERT INTO professionals(id, company_id, first_name) 
  VALUES (1, 1, 'peter') RETURNING *) 
  
  INSERT INTO services(id, professional_id, name) 
  VALUES (1, (select professionals.id from professionals), 'haircut')
  </code></pre>