title: Insert only if row with non uniqe foreign key doesn't already exist in MariaDB
body: <p>I have a table A</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>field</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>valueA</td>
  </tr>
  <tr>
  <td>2</td>
  <td>valueB</td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>and a table B with a reference to table A</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>fk_table_a</th>
  <th>field_a</th>
  <th>field_b</th>
  <th>...</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>2</td>
  <td>2</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I wanna insert something on table B only if it doesn't have already any dataset that has a reference to A (via fk_table_a)</p>
  <p>Unfortunately the foreign fk_table_a key isn't unique and i can't change this fact, so it is potential possible to insert another entry with same foreign key. But i don't want this in my case.</p>
  <p>I use INSERT INTO ... SELECT statement to insert a whole bunch of rows into the table B
  ... the select for this is a bit more extensive but it looks something like this</p>
  <pre><code>INSERT INTO table_b (fk_table_a, field_a, field_b, ...)
     SELECT ot1.id_table_a, ot2.field_a, ot3.field_b
     FROM other_table_1 ot1, 
     JOIN other_table_2 ot2 ...
     JOIN other_table_3 ot3 ...
     ....
  #only insert the current dataset if it ot1.id_table_a doesnt exist already in table_b!
  </code></pre>
  <p>So for any dataset from the select i don't wanna have an entry in table_b, if there is already a dataset with the same fk_table_a ...</p>
  <p>Any ideas?</p>