title: Multiple updates in one sql query
body: <p>I have a table in H2 DB</p>
  
  <pre><code>Order
  -------- 
  id (key)
  MarketId1
  MarketId2
  MarketId3
  ListName1
  ListName2
  ListName3
  </code></pre>
  
  <p>From XML I'm getting list of ListOrder</p>
  
  <pre><code>public final class ListOrder
  {
       public long listId;
       public String Name;
  }
  </code></pre>
  
  <p>So I have 3 prepared statements</p>
  
  <pre><code>"UPDATE Order set " + ListName1 + " = ? WHERE " + MarketId1 + " = ?"
  "UPDATE Order set " + ListName2 + " = ? WHERE " + MarketId2 + " = ?"
  "UPDATE Order set " + ListName3 + " = ? WHERE " + MarketId3 + " = ?" 
  </code></pre>
  
  <p>The in a method I prepare a list of PreparedStament to execute</p>
  
  <pre><code>final PreparedStatement statement1 = connection.prepareStatement(QUERY1);
  final PreparedStatement statement2 = connection.prepareStatement(QUERY2);
  final PreparedStatement statement3 = connection.prepareStatement(QUERY3);
  
      for (ListOrder listOrder: listOrders)
      {
          statement1.setString(1, listOrder.Name);
          statement1.setLong(2, listOrder.listId);
          statement1.addBatch();
  
          statement2.setString(1, listOrder.Name);
          statement2.setLong(2, listName.listId);
          statement2.addBatch();
  
          statement3.setString(1, listName.Name);
          statement3.setLong(2, listOrder.listId);
          statement3.addBatch();
      }
  
      return new ArrayList&lt;PreparedStatement&gt;(){{add(statement1); add(statement2); add(statement3);}};
  </code></pre>
  
  <p>I'm a SQL noob. Is there any better way of doing it? I assume that MarketId 1 2 3 could be the same. ListNames could be null (there will be at least one)</p>
  
  <p>UPDATE:
  In code I would write something like this (prob change to HashMap)</p>
  
  <pre><code>for (ListOrder listOrder: listOrders)
  {
      for(Order order : orders)
      {
           if(order.marketID1 == listOrder.listID)
                order.listName1 = listOrder.Name; //break if no dups
           if(order.marketID2 == listOrder.listID)
                order.listName2 = listOrder.Name;
           if(order.marketID3 == listOrder.listID)
                order.listName3 = listOrder.Name;
      }
  }
  </code></pre>