View previous topic :: View next topic
|
Author |
Message |
bhairon singh rathore
New User
Joined: 19 Jun 2008 Posts: 91 Location: banglore
|
|
|
|
hi all,
Can somebody help me out and provide me equivalent query for the below.
UPDATE TABLE_1
INNER JOIN TABLE_2 ON
TABLE_1.COLUMN-1 = TABLE_2.COLUMN-1
SET TABLE_1.COLUMN-2 = TABLE_2.COLUMN-2.
Regards
Bhairon Singh Rathore |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Code: |
UPDATE TABLE1
SET TABLE1.COL2 = (SELECT TABLE2.COL2
FROM TABLE2
WHERE TABLE2.COL1=TABLE1.COL1)
|
|
|
Back to top |
|
|
bhairon singh rathore
New User
Joined: 19 Jun 2008 Posts: 91 Location: banglore
|
|
|
|
hi Bharath,
I don't think this will work .....
In Below Query
SELECT TABLE2.COL2
FROM TABLE2
WHERE TABLE2.COL1=TABLE1.COL1
1) how can you put column from table1 without joining it with table2
2) After join also how will this query verify that this is updating Right row of the table1
Thanks Anyway. |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi bhairon singh rathore,
Can you access the table2 at first and move the corresponding field to a Working storage and hence can you update that field to the Table1 column.
is that help? |
|
Back to top |
|
|
bhairon singh rathore
New User
Joined: 19 Jun 2008 Posts: 91 Location: banglore
|
|
|
|
Hi Anand,
Yes we can do it thru a cursor very easily.... but i need some equivalent query , if possible for the same . |
|
Back to top |
|
|
anandinmainframe
Active User
Joined: 31 May 2007 Posts: 171 Location: India
|
|
|
|
Hi bhairon singh rathore,
How you are going to update that field by Spufi or Eztrieve or etc... |
|
Back to top |
|
|
Bharath Bhat
Active User
Joined: 20 Mar 2008 Posts: 283 Location: chennai
|
|
|
|
Quote: |
hi Bharath,
I don't think this will work .....
|
That Query works NO MATTER WHAT YOU THINK. Please care enough to run and check rather than making statement based on instincts. There are a lot more things in DB2 than what me or you can think. Use the query for your benefit or don't but don't give out verdicts based on your thoughts.
Quote: |
1) how can you put column from table1 without joining it with table2
2) After join also how will this query verify that this is updating Right row of the table1 |
Good questions. Have you ever heard of the term subquery? If not, its time to learn them.
Please go thru the link if you really care enough to learn.
Subqueries |
|
Back to top |
|
|
|