Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Query - Update column value with data from another column

Status
Not open for further replies.

gust1480

Programmer
Mar 19, 2002
148
PH
Hi,

Can somebody please teach me on how to update a certain column value using another column value?

Ex. I need to get the value from acct field then update the value on the name and country using the value from the acct field and at the same time appending the field name with it.
From

Acct Name Country
FAR John USA
ARD Pier FRANCE
MDO Ming CHINA

To
Acct Name Country
FAR FAR-Name FAR-Country
ARD ARD-Name ARD-Country
MDO MDO-Name MDO-Country

Thanks
 
Hi

Unless there is a trap I missed, should be simple as :
Code:
[b]update[/b] thetable
[b]set[/b] Name = Acct + [green][i]'-Name'[/i][/green], Country = Acct + [green][i]'-Country'[/i][/green]

But I feel would have more logic to request something like this :
Code:
[b]update[/b] thetable
[b]set[/b] Name = Acct + [green][i]'-'[/i][/green] + Name, Country = Acct + [green][i]'-'[/i][/green] + Country

Or actually you have an unknown number of fields and actually you want to automate generating the [tt]update[/tt] statement ?


Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top