title: insert into table with composite primary key columns only
body: <p>I try to run an insert statement (via MySQLdb-python) like this:</p>
  
  <pre><code>insert into LinkTable1ToTable2 (site_id, customer_id) values ('xyz-c1', '123');
  </code></pre>
  
  <p>Only to get the following error:</p>
  
  <pre><code>Error Code: 1062. Duplicate entry 'xyz-c1-123' for key 'PRIMARY'
  </code></pre>
  
  <p>It's a linking table (intermediate table) that links two other tables that have many-to-many relationship. The table consists of two columns that form a composite primary key and looks like this:</p>
  
  <pre><code>    site_id | customer_id
     ---------------------
      xyz-a1  | 121
      xyz-b1  | 122
  </code></pre>
  
  <p>The table schema is:       </p>
  
  <pre><code> Field,        Type,        Null,     Key,    Default,    Extra
  'site_id',     'char(40)',  'NO',    'PRI',    '',        ''
  'customer_id',  'int(11)',   'NO',    'PRI',    '0',       ''
  </code></pre>
  
  <p>After many hours of searching on the Internet and stackoverflow, the only thing I came up with is some flimsy:</p>
  
  <pre><code>insert ignore into LinkTable1ToTable2 (site_id, customer_id) values ('xyz-c1', '123')
  ON DUPLICATE KEY UPDATE site_id=values(site_id), customer_id=values(customer_id);
  </code></pre>
  
  <p>which only returns:</p>
  
  <pre><code>0 row(s) affected
  </code></pre>
  
  <p>and I feel a bit lost...</p>
  
  <p>I need an insert statement that inserts a pair of site_id and customer_id into the table (see the statement in the beginning of the question, please).</p>
  
  <p>Can anyone help?</p>