[thelist] Increment every value in table (MySQL)

Samuel Warren sam at invalidpage.com
Tue Jan 6 09:10:24 CST 2009


Jason,
not all database structures require a parent/child relationship which
necessitates foreign keys.

Chris,

I'm sure what your looking for can be done, probably with a cursor
(unfortunately).

Basically This query will give you the column names:

SELECT name FROM syscolumns
WHERE id = (SELECT id FROM sysobjects
WHERE name= '<TableName>')
ORDER by colorder;

If you drop those names into a cursor you should be able to use them to run
out Update queries from there. Never done it before, but I'm pretty sure
it's possible.


-----------------------------------------------------------------------
Thanks
Samuel Warren
-----------------------------------------------------------------------


On Tue, Jan 6, 2009 at 7:40 AM, Jason Handby <jason.handby at corestar.co.uk>wrote:

> > 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.
>
>
> If *every* value in the table is multiplied by 1.35, that means anything
> else that references this table will have its foreign key relationship
> broken (as for every record in your table the primary key will change).
>
> So, you'll need to either a) exclude some fields in your table from the
> multiplication (e.g. if you have a numeric ID field) or b) carry out the
> same multiplication process on the relevant fields in any other table
> that refers to this one, so that the reference is preserved. Either way
> your database structure sounds a bit weird :-)
>
>
>
> Jason
>
>
> --
>
> * * 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