|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Update Statement Between Two Tables
Hi,
I have a table with the Following fields City, Txns in the table BOB_BK. There is another table "SUM_MONTH" with the same two fields with some additional information. Now I want to get Value in the field TXNS of BOB_BK in "SUM_MONTH" Table. But when i write the following query UPDATE SUM_MONTH A SET A.TXNS = B.TXNS FROM BOB_BK B, SUM_MONTH A WHERE A.CITY = B.CITY... It gives me a error saying SQL not complete. Then I Tried the following query UPDATE SUM_MONTH A SET A.TXNS = (SELECT B.TXNS FROM BOB_BK B, SUM_MONTH A WHERE B.CITY = A.CITY).. It gives an error saying subquery returning more than one value. but if i remove the = sign and replace it by IN it still gives as error saying "= sign missing". So how do i run this update??? Thanks in Advance Suresh |
|
#2
|
|||
|
|||
|
Code:
UPDATE SUM_MONTH A SET A.TXNS = (SELECT b.TXNS FROM BOB_BK B WHERE B.CITY = A.CITY) where city in (select city from bob_bk) |
|
#3
|
|||
|
|||
|
THis is not working.Still gives me an error ORA-01427: single-row subquery returns more than one row.
The latest Query... UPDATE SUM_MONTH A SET A.TXN_COUNT_M = (SELECT b.TRNS FROM BOB_BK B WHERE A.N_CITY_CODE = B.N_CITY_CODE AND A.BANK_CODE = '00001') WHERE N_CITY_CODE in (select N_CITY_CODE from bob_bk); Can you suggest something else... |
|
#4
|
|||
|
|||
|
So, for some cities in the SUM_MONTH tables there are multiple records in the BOB_BK table. Which of those rows shall you choose? Or should you do an aggregation instead? It's your choice.
|
|
#5
|
|||
|
|||
|
Obviously I had to use the aggregate function. and it worked. Thanks a lot for your help buddy... Helped me restore the data in the production server. Thanks a million again.....
|
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Update Statement Between Two Tables |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|