SirChick Posted November 16, 2007 Share Posted November 16, 2007 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.. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 16, 2007 Share Posted November 16, 2007 try UPDATE mytable SET DayBeforeProfit= YesterdayProfit , YesterdayProfit = ProfitToday , ProfitToday = 0 Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 16, 2007 Author Share Posted November 16, 2007 <? 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.. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 16, 2007 Share Posted November 16, 2007 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()); ?> Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 16, 2007 Author Share Posted November 16, 2007 well i only had one record for this test but ill give your one a try.. Quote Link to comment Share on other sites More sharing options...
SirChick Posted November 16, 2007 Author Share Posted November 16, 2007 works a treat. Thankyou Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.