Home » SQL & PL/SQL » SQL & PL/SQL » Copying almost all columns from row to new row to the same table (Almost like insert into table1 (select * from table1))
Copying almost all columns from row to new row to the same table [message #364592] Tue, 09 December 2008 04:07 Go to next message
pc131
Messages: 36
Registered: May 2006
Member
Hi
I have table1 with 4 columns: col1, col2, col3, col4. I've been wondering if I could do insert like this.

Insert into table1 ('my_value', select col2, col3, col4 from table1 where condition).....

I think it doesnt work for me.

It is almost copying rows (to the same table) but I want to change value in 1st column and take rest columns as copy of similar row...

Anybody coped with that?

Thanks in advance
Tom

[Updated on: Tue, 09 December 2008 04:12]

Report message to a moderator

Re: Copying almost all columns from row to new row to the same table [message #364593 is a reply to message #364592] Tue, 09 December 2008 04:14 Go to previous messageGo to next message
cookiemonster
Messages: 12403
Registered: September 2008
Location: Rainy Manchester
Senior Member
Please read the orafaq forum guide:
http://www.orafaq.com/forum/t/88153/0/
And format your post next time.

Try putting 'my_value' after the select.
Re: Copying almost all columns from row to new row to the same table [message #364600 is a reply to message #364592] Tue, 09 December 2008 04:23 Go to previous messageGo to next message
karthick_arp@yahoo.com
Messages: 6
Registered: November 2006
Location: India
Junior Member

Try like this

Insert into table1 
select 'my_value', col2, col3, col4 
  from table1 
 where condition...
Re: Copying almost all columns from row to new row to the same table [message #364615 is a reply to message #364592] Tue, 09 December 2008 05:05 Go to previous message
pc131
Messages: 36
Registered: May 2006
Member
Yes it works

Thanks
Tom
Previous Topic: Database trigger question (merged)
Next Topic: how to fix ORA-00904 Error
Goto Forum:
  


Current Time: Sat Dec 03 11:42:26 CST 2016

Total time taken to generate the page: 0.05004 seconds