Jump to content

[SOLVED] Moving field value to other field in one query?


SirChick

Recommended Posts

Is it possible to do this :

 

Say i got 3 fields:

YesterdayProfit

 

DayBeforeProfit

 

ProfitToday

 

Now in a query is it possible to move ProfitToday to become YesterdayProfit and YesterdayProfit (before the first change) to become DayBeforeProfit

 

All in one query? Does it have a move feature that I am looking for, or do i have to obtain the values from each then INSERT in to the correct field which is the longer method..

<?
include("include.php");

$GetCasinos = mysql_query("SELECT * FROM citycasinos");

While (mysql_fetch_assoc($GetCasinos)){
$Update = "UPDATE citycasinos SET DayBeforeProfit= YesterdayProfit ,
  YesterdayProfit = ProfitToday ,
  ProfitToday = 0";
$result = mysql_query($Update) or die(mysql_error());
}
?>

 

Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\test2.php on line 10

 

Did that go into an infinite loop :S ?

 

 

Just to add the query didn't work..

If you have 1000 records then you are updating all 1000 of them 1000 times. All you need is my query to update the whole table.

<?
include("include.php");

$Update = "UPDATE citycasinos SET DayBeforeProfit= YesterdayProfit ,
  YesterdayProfit = ProfitToday ,
  ProfitToday = 0";
$result = mysql_query($Update) or die(mysql_error());

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.