title: SQL: UPDATE many-to-many's intermediate table
body: <p>I have table <em>A</em> and table <em>B</em>. Relation between them done using intermediate table <em>AB</em>, which stores ID's from both. </p>
  
  <pre><code>Table A 
  
  ID integer
  Value varchar(MAX)
  
  Table B 
  
  ID integer
  Value varchar(MAX)
  
  Table AB 
  
  AID integer
  BID integer
  </code></pre>
  
  <p>I can select needed data with <code>JOIN</code>'s, but how to write data into <code>AB</code>? 
  I mean if I'll get <code>AID</code> and list of <code>integer</code>'s (done as custom type <em>Array_Integer</em> <code>table(ID integer)</code>) , which is <code>BID</code>, how to update relations in <code>AB</code> with a received list of <code>BID</code>'s?
  I can do a lot of dirty and manually work, but I'm looking for a more true way.</p>
  
  <p>UPD: check schema on pastebin — <a href="http://pastebin.com/BeKm2h3F" rel="nofollow">http://pastebin.com/BeKm2h3F</a> </p>