aspose file tools
The moose likes JDBC and the fly likes UPDATE with select statment Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "UPDATE with select statment" Watch "UPDATE with select statment" New topic
Author

UPDATE with select statment

sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643

eno name phone
----------- -------------------- ----------
1 Quick and Dirty 1112223333
2 Starve Bucks 1112224444
3 JeffyGrease 1114443333
4 Stuffed Stuff 1112225555

RecommendedList
eno eateryname phone
----------- -------------------- ----------
4 Stuffed Stuff 7772225555
11 Pleasant Regrets 9992223333
12 Try Harder 8882224444
23 BBB's Choice 1114443333
1 Quick and Dirty 8882223333

" UPDATE Eateries SET Eateries.phone =
(SELECT x.phone from RecommendedList x WHERE x.eno=Eateries.eno)
WHERE Eateries.eno IN (SELECT eno FROM RecommendedList)
Referring to tables Eateries and RecommendedList in the scenario above, how many Eateries records are updated by the statement? "



the answer is 0.i can't fine how it comes ti zero.
Ranjan Barua
Greenhorn

Joined: Sep 08, 2009
Posts: 5
Hi Aruna,

i have checked your query with given data, but it returns me outout "2 rows updated".

please try it again, i think there is something wrong with your tool which you are using.


Ranjan Kumar Barua
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
it can't be happen no.isn't any error in this statments?
Ranjan Barua
Greenhorn

Joined: Sep 08, 2009
Posts: 5
No there is no problem with your statement.
sameera liyanage
Ranch Hand

Joined: Nov 25, 2008
Posts: 643
ya ,finally i got it .but i got 2 rows.

 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: UPDATE with select statment
 
Similar Threads
showing resultset
java sql query
How To work With JDBC Type 2 Driver
Nested Reslutsets
The method setAttribute(String, Object) in the type HttpSession is not applicable for