Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 11th, 2005, 02:02 AM
Authorized User
 
Join Date: Sep 2004
Location: Muscat, , Oman.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update data from another table

hi:

i have 2 tables. t1 and t2. im trying to insert data in a field in t1 from a field in t2. the field is called F. t1 has data in its other columns but empty in the F. thats why i want to insert the data from t2 to t1 in the respective column F. i wrote the below code:

UPDATE T1
SET F= ( SELECT F FROM T2 WHERE T2.Key = T1.KEY)

i get this error:
ORA-01427: single-row subquery returns more than one row

kindly help me. where am i going wrong?

Thanks

Reply With Quote
  #2 (permalink)  
Old July 11th, 2005, 05:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

The error message says it all. You have more than one row in T2 where the T2.Key value is equal to some T1.Key value. The subquery returns all the rows in T2 where the Key values are equal. Since there is more than one row for some T1.Key, the error is generated because which value of F from the several rows should it use to update that row in T1?

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
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 Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update one table to another table using DTS in SQL Printmaker SQL Language 0 July 24th, 2007 07:17 AM
How to Update one table with other table data? ramk_1978 SQL Language 2 May 26th, 2006 12:51 AM
update table with an ID Num from different table scoobie PHP How-To 12 January 25th, 2005 12:28 PM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM
Update SQL table with data from FoxPro system sofya SQL Server 2000 6 November 4th, 2004 06:45 PM



All times are GMT -4. The time now is 12:13 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.