If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Need a little bit of help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-15-03, 21:06
ChrisWBates ChrisWBates is offline
Registered User
 
Join Date: Nov 2003
Posts: 21
Need a little bit of help

Need help
This may seem like a dumb question, but here is what I am trying to do,

Lets say, I have a TABLE that has colums

A B C D

Now, I have added a 5th colum E

I want to populate E with D

I can't seem to get the insert command right,

Anyone ??
Reply With Quote
  #2 (permalink)  
Old 11-15-03, 23:07
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
Hey,

update table t1
set e = (
select t2.d
from table t2
where t1.rowid = t2.rowid);

A more obvious query is to try

update table
set e = (select b from table)

This will not work with the returned error message :

ORA-01427: single-row subquery returns more than one row

This essentially means that for each single row you are trying to update the value e to the results of a query that returns > 1 row.

Cheers.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.
Reply With Quote
  #3 (permalink)  
Old 11-17-03, 03:44
ivon ivon is offline
Registered User
 
Join Date: Nov 2002
Posts: 272
Quote:
Originally posted by r123456
Hey,

update table t1
set e = (
select t2.d
from table t2
where t1.rowid = t2.rowid);
On Oracle,
update t1 set e = d;
would work like a charm.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On