Greetings all. I'm not sure if this belongs here or in php forum but...
I have a MySQL database accessed via PHP. I've written query_update_1 (below) to modify "column_2" to '9' when column_1 is between a specified range.
Current
|column_1| column_2| column_3|
____________________________
| 5000 | 7 | Null |
| 5001 | 7 | Null |
| 5002 | Null | Null |
| 5003 | Null | Null |
<code>
$query_update_1 = "update Table set column_2 = '9' where column_1 between '5002' and '5003'";
$result_update_1 = mysql_query($query_update_1);
if(!$result_update_1){
$error_message = "Number insert failed. Sorry";
require("error_page_2.php");
exit;
}
</code>
Query Update_1 Result
| column_1 | column_2| column_3|
_____________________________
| 5000 | 7 | Null |
| 5001 | 7 | Null |
| 5002 | 9 | Null |
| 5003 | 9 | Null |
Now, what I want to do is run another query (or one at the same time) to modify and carry the data in column_1 field to the column_3 field with a text mod, ie:
Desired Update_2 Result.
| column_1 | column_2 | column_3|
_____________________________
| 5000 | 7 | Null |
| 5001 | 7 | Null |
| 5002 | 9 | Stat 5002 |
| 5003 | 9 | Stat 5003 |
Can this be achieved within the same query, or do I need to set up a loop or..??
Any and all input much appreciated.
TIA
Bruce
I have a MySQL database accessed via PHP. I've written query_update_1 (below) to modify "column_2" to '9' when column_1 is between a specified range.
Current
|column_1| column_2| column_3|
____________________________
| 5000 | 7 | Null |
| 5001 | 7 | Null |
| 5002 | Null | Null |
| 5003 | Null | Null |
<code>
$query_update_1 = "update Table set column_2 = '9' where column_1 between '5002' and '5003'";
$result_update_1 = mysql_query($query_update_1);
if(!$result_update_1){
$error_message = "Number insert failed. Sorry";
require("error_page_2.php");
exit;
}
</code>
Query Update_1 Result
| column_1 | column_2| column_3|
_____________________________
| 5000 | 7 | Null |
| 5001 | 7 | Null |
| 5002 | 9 | Null |
| 5003 | 9 | Null |
Now, what I want to do is run another query (or one at the same time) to modify and carry the data in column_1 field to the column_3 field with a text mod, ie:
Desired Update_2 Result.
| column_1 | column_2 | column_3|
_____________________________
| 5000 | 7 | Null |
| 5001 | 7 | Null |
| 5002 | 9 | Stat 5002 |
| 5003 | 9 | Stat 5003 |
Can this be achieved within the same query, or do I need to set up a loop or..??
Any and all input much appreciated.
TIA
Bruce