Current location: Hot Scripts Forums » Programming Languages » PHP » mysql rounding help

mysql rounding help

Reply
  #1 (permalink)  
Old 07-03-09, 05:16 AM
Regan Shepherd Regan Shepherd is offline
New Member
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mysql rounding help

Hi,

I'm new to mysql I'm try to do this… see below.
I don't need any PHP code as I'm just trying to update the database via mysql with an sql query.

From the table ic_option_values
Select all of the price_change values that are not equal to 0.
Multiply these by 1.55
Round the values to the nearest whole number

Don't laugh… here's my attempt.

UPDATE *
FROM `ic_option_values`
WHERE `price_change` !=0
SUM(`price_change`* 1.55)
ROUND (`price_change`, 0)

Any help would be most appreciated.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-03-09, 09:11 AM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 2,785
Thanks: 13
Thanked 9 Times in 8 Posts
Unless I misunderstand your intent, I don't think you want to SUM the values. That'll basically add them all together, resulting in a single value. Is that what you want to do, or....?



Quote:
Originally Posted by Regan Shepherd View Post
Hi,

I'm new to mysql I'm try to do this… see below.
I don't need any PHP code as I'm just trying to update the database via mysql with an sql query.

From the table ic_option_values
Select all of the price_change values that are not equal to 0.
Multiply these by 1.55
Round the values to the nearest whole number

Don't laugh… here's my attempt.

UPDATE *
FROM `ic_option_values`
WHERE `price_change` !=0
SUM(`price_change`* 1.55)
ROUND (`price_change`, 0)

Any help would be most appreciated.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data (scroll down)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-03-09, 07:37 PM
Jcbones Jcbones is offline
Coding Addict
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 269
Thanks: 3
Thanked 3 Times in 3 Posts
Your query should probably be.

Code:
UPDATE `ic_option_values` 
SET `price_change` = ROUND(`price_change` * 1.55) 
WHERE `price_change`!=0
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-05-09, 09:17 PM
Regan Shepherd Regan Shepherd is offline
New Member
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Jcbones… it worked!!

Wanna be coder… I don't think so… great work… thanks again. Cheers!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Useful MySQL Resources ptesone Database 29 10-14-09 04:04 AM
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 03:22 AM
MySql Labyrinth moron Database 4 02-22-08 03:46 AM


All times are GMT -5. The time now is 11:14 PM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.