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..

Link to comment
Share on other sites

<?
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..

Link to comment
Share on other sites

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());

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.