Computing.Net > Forums > Programming > My Sql calculation query

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

My Sql calculation query

Reply to Message Icon

Name: ian_ok
Date: April 15, 2005 at 10:24:12 Pacific
OS: win xp 98 & 2k
CPU/Ram: p3 512
Comment:

I'm using MQ Sql to hold my data and now I wish to do a calculation with 1 field and return the value to another field:

Eg
Field 1 = 100
Field 2 = Field 1 * 15.6

I can edit the Mqsql in php admin, would I just simply add Field 1 * 15.6 to field 1 or do i need to add brackets etc?

Thanks Ian


Sanlucar de Barrameda



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: April 15, 2005 at 18:31:50 Pacific
Reply:

Is this a one-time update that you want to do to the entire database? I don't think you can do that through the MySQL admin - I could be wrong.

It would be pretty easy to write a PHP/ASP page to run once that would do it for you. Just do a select statement to return all records and then loop through all of them and update the new column.

Just a thought though, is this value ALWAYS going to be (Field 1 * 15.6) or can it change after you have made the update. If it will always be 15.6 times Field-1, then it would just make more sense to modify your code whenever you need that value instead of having two values int he database that might get out of sync.

Michael J


0

Response Number 2
Name: ian_ok
Date: April 15, 2005 at 20:50:58 Pacific
Reply:

Field one is a price, field two will always be the value of field one times by 15.6 (well 166.386 the old Spanish peseta)

The current output is in a php file

Ian


Sanlucar de Barrameda


0

Response Number 3
Name: ian_ok
Date: April 15, 2005 at 22:30:18 Pacific
Reply:

This is what I've tried.....It doesn't work, but I think I'm on the right line...any tips?

Ian
Price in Pts: <?php
define("pst",166.386);
$total=0.00;
$total=renderSingleListingItemRaw($listingID, "price_es")*pst ;
$total = number_format($total, 2);
echo $total;
?>


Sanlucar de Barrameda


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: My Sql calculation query

Need help with an SQL join query www.computing.net/answers/programming/need-help-with-an-sql-join-query/13358.html

my sql and php code www.computing.net/answers/programming/my-sql-and-php-code/10134.html

java sql www.computing.net/answers/programming/java-sql/4360.html