Gossamer Forum
Home : General : Databases and SQL :

UPDATE TABLE

Quote Reply
UPDATE TABLE
Hi there,

I am hoping that what I would like to do is easy!

I have a table (product) and two fields (item and altitem)

I want to update everything in altitem with what is in item, ie. ITEM has 2293, I would like ALTITEM = 2293

Any help would be great

I have little clues on how to do this as I thought a variable would be needed to ensure that I am updating the correct record.

Thanks

Todd
Quote Reply
Re: [trcandy] UPDATE TABLE In reply to
This beign run by PHP/Perl/Command line? All depends on what kind of code we supply you with Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [trcandy] UPDATE TABLE In reply to
UPDATE products SET altitem = item

That will set altitem to the value of item for each individual row (and _every_ row!)

Last edited by:

Paul: Oct 9, 2002, 7:40 AM
Quote Reply
Re: [Paul] UPDATE TABLE In reply to
WhoopsyeeeeeBlush

It gave me an error message but actually did the update !!



WHOO HOO

Wink

Thank you Paul !!


If the ITEM number had two characters at the start (AA8989) that I do not want how do I trim them out?

I.e. AA8989 should go into other field as 8989Unsure

Last edited by:

trcandy: Oct 9, 2002, 7:57 AM
Quote Reply
Re: [trcandy] UPDATE TABLE In reply to
UPDATE products SET altitem = SUBSTRING(item FROM 3)

or

UPDATE products SET altitem = SUBSTRING(item, 3)

Last edited by:

Paul: Oct 9, 2002, 8:02 AM
Quote Reply
Re: [Paul] UPDATE TABLE In reply to
thank you!!



This forum is GREATSly



Cheers!
Quote Reply
Re: [trcandy] UPDATE TABLE In reply to
Don't you mean "Paul you are great!" ?

Wink

s/Paul/mysql docs/;
Quote Reply
Re: [Paul] UPDATE TABLE In reply to
It's your modesty and humble nature that make these forums great. Laugh

Sean
Quote Reply
Re: [SeanP] UPDATE TABLE In reply to
You noticed the regex at the bottom though right Smile
Quote Reply
Re: [Paul] UPDATE TABLE In reply to
Laugh