Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Force Calc via sql statement 1

Status
Not open for further replies.

shamrox7

Programmer
Joined
Aug 1, 2007
Messages
14
Location
US
Ok, I'm not sure if this is possible but it should would be handy.
I have a database full of records, including a few fields with financial data. The user wants a new field added to calc the profit based off of two other fields. I have written code that will calc it on the users webpage for new records and save the data but what about all the old records in the database? Is there a way to write a query or statement of some sort that I could run right in phpmyadmin and have it do the calculation and store the output in this new field for every record?

Thanks in advance.
 
update daTable
set daNewColumn = 937*oldCol1 + oldCol2
where daNewColumn is null

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top