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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Data within a Table

Status
Not open for further replies.

bobby13

Technical User
Jun 18, 2003
93
GB
HI I was wondering if someone can assist me on how I can copy a collumn within a table into another collumn within the same table.

Basically I have a table called bazes which has a collumn called base_name, within the same table I have inserted a new collumn called official_base_name.

So I want to populate the collumn official_base_name with the data in Base_name, how do I do that I tried....

SQL>update bazes
2 set official_base_name = bazes.base_name
0 rows updated

I also tried...

SQL> insert into bazes (base_name, official_base_name)
2 select base_name, official_base_name
3 from bases
4 where base_name <> null;

0 rows created.

Can anyone suggest a solution?

[afro]

Regards
Bobby
 
Problem has been resolved,I had the answer but was using the wrong syntax and making my sql very complicated, when all I needed to do was

update bazes
set official_base_name = base_name;

The new collumn was automatically updated.

Regards
Bobby
 
Bobby,

Your first code set is the set that you want. The problem is, you have no rows in that copy of your bazes table. You can confirm this with:
Code:
select count(*) from bazes;

Let us know,

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I can provide you with low-cost, remote Database Administration services: see our website and contact me via www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top