<p>Suppose there is a fully populated array of data String[n][3] myData.</p>

<p>I want to do this:</p>

<pre><code>for (String[] row : myData)
{
   SQL = "update mytable set col3 = row[2]
   where col1 = row[0] and col2=row[1];" 
}
</code></pre>

<p>Obviously I've left a lot out, but I want to express the idea as succinctly as possible.</p>

<p>Is there a simple way of doing this in a single DB command?
How about a not so simple way?</p>

<p>EDITS:
Data is not coming from another table (it's a web form submission - Multiple Choice exam)<br>
Seeing as the app is web facing, It's got to be injection proof.  Parameterized Queries are my preferred way of going.<br>
I'm using MS-SQL Server 2005</p>

<p>EDIT:Closing, and re-asking as <a href="https://stackoverflow.com/questions/184471/multiple-db-updates">Multiple DB Updates:</a></p>

<p>EDIT: Re-opened, as this appears to be a popular question</p>

You can make a big string like:
```
```
for (String[] row : myData)
{
   SQL += "update mytable set col3 = row[2]
   where col1 = row[0] and col2=row[1];" 
}

sqlDriver.doInsertQuery(SQL); // change this to your way of inserting into the db
```
```
And just commit it all at once. I'm not very good with SQL so that's how i would do it.
The sql engine will just split it by the ';' and do separate inserts on its own. It's ok to add it all in a string though. It's kind the same as if u copy a big string with multiple updates/inserts into the sql prompt