Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 28th, 2004, 05:33 AM
aspuser25 aspuser25 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 141 aspuser25 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Red face update statement query

hi

i have 2 tables table1 with columns LOGINID and NAME. table2 has columns NAME, ADDRESS, BILL_NO, DUE_AMT. Have created a new column in table2 named LOGINID and want to insert all the values of column LOGINID of table1 into the LOGINID column of table2.

I know i am writing an incorrect update command :
UPDATE TABLE2 SET TABLE2.LOGINID=
(SELECT TABLE1.LOGINID FROM TABLE1, TABLE2
WHERE TABLE1.NAME=TABLE2.NAME)

Now i am getting around 100 rows from the select query...how to resolve this ...i know this is simple but i donot have mcuh knowledge
pls do respnond

thanks

Reply With Quote
  #2  
Old October 28th, 2004, 09:13 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 6
Your subquery is returning more than one record, please note the modification marked in red.

Your query:
-----------
UPDATE TABLE2 SET TABLE2.LOGINID =
(SELECT TABLE1.LOGINID FROM TABLE1, TABLE2
WHERE TABLE1.NAME=TABLE2.NAME)

Solution: Please remove the TABLE2 from the subquery, as mentioned below;

UPDATE TABLE2 SET TABLE2.LOGINID=
(SELECT TABLE1.LOGINID FROM TABLE1
WHERE TABLE1.NAME=TABLE2.NAME)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > update statement query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT