I have a Large\_table with fields named 1 (ID) thru 10 and 10k plus rows. 

The Update statement causes things to slow down to a point where some records fail to update at all.

If I run 

```
UPDATE Large_table SET SOME_FIELD = '$testdata' 

```

it takes <1 sec from the PHP ,so its the WHERE clause that is the issue.

Running 

```
UPDATE Large_table SET SOME_FIELD = 'apple' WHERE ID ='1' 

```

from the php where it is in the foreach loop and so runs 10k times >30 sec and time out.

I need to: 
1 fetch all the rows ( could fetch single row if i do a pre select but that seams like doubling up and the fetch appears efficient and quick).
 Fetching all the data as in a lot of rows we need all the data in others there is only some fields, but that changes daily.

```
$stmt = $conn->prepare("SELECT * FROM Large_table "); $stmt->execute(); // Works quick.

foreach ($stmt as $row){
        echo $row['1'];// works at .8 sec sometimes less
        $testdata = 'apple';

//PHP CONSTRUCT THE OUTPUT Field for each row differently depending upon id and other feilds - so for testing lets call it $testdata = 'apple' and assume it changes as the issue is not in this part

    $stmt = $conn->prepare("UPDATE Large_table SET SOME_FIELD = '$testdata' WHERE ID = '$row['1']' "); $stmt->execute();                

        }

```

I tried the CASE THEN WHEN complied approach but the sql statement becomes horrendous so surly cannot be the best way of doing this. 

So What is the quickest most efficient way to achieve this ?