[thelist] Increment every value in table (MySQL)

Barry Woolgar barry at burnthebook.co.uk
Tue Jan 6 09:09:52 CST 2009


> I am looking for a query something like UPDATE table_name 
> SET * = * x 1.35 so I don't need to know field names.

Ah I see what you mean, if you don't mind doing it in a couple of queries
and a bit of programming you could run a 'SHOW COLUMNS FROM table', loop
through the results to get the field names, and build your update query on
the fly.

There is probably a more elegant way to go about this, which I'd be
interested in seeing if anyone knows it.

Thanks

Barry

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Chris Price
Sent: 06 January 2009 11:44
To: thelist at lists.evolt.org
Subject: Re: [thelist] Increment every value in table (MySQL)

Thanks

but I am looking for a query something like UPDATE table_name SET * = * 
x 1.35 so I don't need to know field names.

Barry Woolgar wrote:
>> I have a table with only numbers in it and I want to increase every value
>>     
> by 35%.
>
> Assuming MySQL:
>
> UPDATE table SET `field` = `field` * 1.35;
>
> Be sure to back up first, just in case my brain is also not functioning...
> ;)

-- 

Kind Regards


  Chris Price
  Choctaw

chris.price at choctaw.co.uk <mailto:chris.price at choctaw.co.uk>
www.choctaw.co.uk <http://www.choctaw.co.uk>

Tel. 01524 825 245
Mob. 0777 451 4488

Beauty is in the Eye of the Beholder while
Excellence is in the Hand of the Professional

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 >> Sent on behalf of Choctaw Media Ltd <<

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Choctaw Media Limited is a company registered in
England and Wales with company number 04627649

Registered Office: Lonsdale Partners, Priory Close,
St Mary's Gate, Lancaster LA1 1XB . United Kingdom

-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 




More information about the thelist mailing list