title: My Sql Query - Insert new record in table under specific conditions from other two tables and avoid duplicate entries
body: <p>I am going nuts trying to figure out this all day but without success. </p>
  
  <p>I have 3 tables called: selections, auctions, game</p>
  
  <p>What I need to achieve is insert 3 new records in 'selections' table for every game which is written in 'auctions' table (they are marked in both tables with ID number) but some necessary data is also in 'game' table which is connected with 'auctions' table (with BetfairMark). And to avoid duplicate entry if there are any. </p>
  
  <p>'<strong><em>Auctions</em></strong>' table have this columns: 
  <strong>id</strong> (writen in table from before and it's connection with 'selections' table) 
  <strong>BetfairMark</strong> (must be the same as 'BetfairMarketID' from 'game' to properly connect 'auctions' table with 'game' table),
  <strong>title</strong> (written in table from before)</p>
  
  <p>'<strong><em>Selections</em></strong>' table have columns:<br>
  <strong>id</strong> (which is auto-increasing number for every new record generated in this table),
  <strong>auctionid</strong> (this is number which must be created here with this query to be the same as is 'id' from auctions table)
  <strong>order</strong> (each of 3 records must have generated with query order numbers 1, 2, 3)
  <strong>odds</strong> (need to get proper odds number for each record from Game table)  </p>
  
  <p>'<strong><em>Game</em></strong>' table have this columns:
  <strong>BetfairMarketID</strong> (which need to be the same number as 'BetfairMark' from auctions table to figure out right row to take data from this table)
  <strong>ABack</strong> (odds number which need to go in selections new record under 'order' 1)
  <strong>BBack</strong> (odds number which need to go in selections new record under 'order' 2)
  <strong>DrawBack</strong> (odds number which need to go in selections new record under 'order' 3)</p>
  
  <p>To summarize need to achieve this:
  - insert 3 new records in 'selections' table where every record need to be marked with order 1, 2 and 3. Must show there proper 'auctionid' number according to auctions table relationship.
  - if there will be duplicate record entry (by this mean some record will have same 'auctionid' number AND same 'order' number record will not be inserted.
  - in those 3 new records must input 'odds' numbers from 'ABack', 'BBack', 'DrawBack' columns in 'game' table (which is in relationship with 'auctions' table according to BetfairMarketID/BetfairMark same number). </p>
  
  <p>I tryed this which hoping is on right track but need a lot of modifications:</p>
  
  <pre><code>INSERT INTO selections (selections.auctionid, selections.order, selections.odds)
  VALUES 
  ((SELECT id FROM auctions), '1', (select ABack FROM game, auctions WHERE game.BetfairMarketID = auctions.BetfairMark)),
  ((SELECT id FROM auctions), '2', (select BBack FROM game, auctions WHERE game.BetfairMarketID = BetfairMark)),
  ((SELECT id FROM auctions), '3', (select DrawBack FROM game, auctions WHERE game.BetfairMarketID = BetfairMark))
  </code></pre>
  
  <p>But receiving this error: [Err] 1242 - Subquery returns more than 1 row</p>