Current location: Hot Scripts Forums » Programming Languages » PHP » Simple mySQL Question, Multiplying Entire Column


Simple mySQL Question, Multiplying Entire Column

Reply
  #1 (permalink)  
Old 07-21-05, 03:48 PM
Luke2 Luke2 is offline
New Member
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Simple mySQL Question, Multiplying Entire Column

Hello there. Quick question; how can I multiply all the entries in an SQL column by a set amount. Many thanks. Luke.

Example:

Column
20 ---New Value (*2) --> 40
30 ---New Value (*2) --> 60
20 ---New Value (*2) --> 40
5 ---New Value (*2) --> 10
100 ---New Value (*2) --> 200
Reply With Quote
  #2 (permalink)  
Old 07-21-05, 07:41 PM
404 404 is offline
Newbie Coder
 
Join Date: Nov 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Not sure what you mean but you can do this:
PHP Code:

$query mysql_query("SELECT * FROM whatever");

while (
$result mysql_fetch_array($query)){
$multiply $result[mathrow]*5//while 5 can be anything you want
}

echo 
$multiply

Last edited by 404; 07-21-05 at 07:46 PM. Reason: wrong example
Reply With Quote
  #3 (permalink)  
Old 07-21-05, 08:00 PM
Luke2 Luke2 is offline
New Member
 
Join Date: Jul 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks 404. This was the code that I ended up using, but I see that yours would be useful, especially for more advanced operations.

PHP Code:

UPDATE table SET somevalue=somevalue*
I knew it would be simple, just needed some logic!
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
Simple mysql question nicpon PHP 0 06-25-05 05:45 PM
I most definately suggest DevelopingCentral.com For Any Website Design/Development! Salty777 General Advertisements 2 10-01-04 04:27 AM
How to change a column value in mysql NewTonez PHP 3 09-12-04 09:01 PM
Simple question kashi PHP 5 08-13-04 10:23 PM
need help creating tables in mysql (VERY SIMPLE QUESTION) meaculpa1113 PHP 2 03-26-04 12:32 AM


All times are GMT -5. The time now is 06:56 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.