Home » SQL & PL/SQL » SQL & PL/SQL » how to copy one column values to other column in same table
how to copy one column values to other column in same table [message #378306] Mon, 29 December 2008 21:07 Go to next message
radhavijaym
Messages: 65
Registered: December 2008
Location: singapore
Member
hi,
i had two colmns as col1 and col2 in table tab1
initially col1 is blank ie doest not have any values and col2 have values.
now i need to copy the same values in col2 to col1.
how to write the update statement

update tab1 set col1=col2
is this correct.
Re: how to copy one column values to other column in same table [message #378307 is a reply to message #378306] Mon, 29 December 2008 21:09 Go to previous messageGo to next message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Have you tried it?
Re: how to copy one column values to other column in same table [message #378311 is a reply to message #378307] Mon, 29 December 2008 21:27 Go to previous messageGo to next message
radhavijaym
Messages: 65
Registered: December 2008
Location: singapore
Member
i had given u the query what i had written

update tab1 set col1=col2
Re: how to copy one column values to other column in same table [message #378317 is a reply to message #378311] Mon, 29 December 2008 23:59 Go to previous messageGo to next message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
And what happened when you ran that query?
Re: how to copy one column values to other column in same table [message #378319 is a reply to message #378306] Tue, 30 December 2008 00:05 Go to previous messageGo to next message
panyam
Messages: 146
Registered: May 2008
Senior Member
Hi RadhaVijayam,

When ever you are posting your question Pls post what u have done.
Also read the Forum guidelines before proceeding.

How ever w.r.t to your question

SQL> create table test ( col1 varchar2(20) , col2 varchar2(20));

Table created.

SQL> insert into test (col2) values ('Rav');

1 row created.

SQL> ed
Wrote file afiedt.buf

  1* insert into test (col2) values ('Ram')
SQL> /

1 row created.

SQL> ed
Wrote file afiedt.buf

  1* insert into test (col2) values ('Rak')
SQL> /

1 row created.

SQL> select * from test;

COL1                 COL2
-------------------- --------------------
                     Rav
                     Ram
                     Rak

SQL> update test set col1 = col2;

3 rows updated.

SQL> select * from test;

COL1                 COL2
-------------------- --------------------
Rav                  Rav
Ram                  Ram
Rak                  Rak


Re: how to copy one column values to other column in same table [message #378323 is a reply to message #378319] Tue, 30 December 2008 00:33 Go to previous messageGo to next message
Littlefoot
Messages: 20895
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
panyam
How ever w.r.t to your question
Excuse me? ./fa/1600/0/
Re: how to copy one column values to other column in same table [message #378330 is a reply to message #378323] Tue, 30 December 2008 01:04 Go to previous message
panyam
Messages: 146
Registered: May 2008
Senior Member
Sorry ...still the messaging habbit i have ...It will take bit time to leave that. Laughing

w.r.t -> With Respect to

[Updated on: Tue, 30 December 2008 01:05]

Report message to a moderator

Previous Topic: condition using not null
Next Topic: Inline Attachment (Mail Triggering)
Goto Forum:
  


Current Time: Mon Dec 05 15:05:15 CST 2016

Total time taken to generate the page: 0.15967 seconds