UPDATE temp_test
SET country_i = (select a.country_code from temp_test2 a,temp_test c
where c.country_i is null and
a.active = 'A' and c.created_by = a.partner_by)
Asked
Active
Viewed 120 times
0
Lalit Kumar B
- 45,678
- 12
- 90
- 118
Prianka Singh
- 5
- 3
-
here is answer to your question http://stackoverflow.com/questions/3361768/how-to-copy-data-from-one-column-to-other-column – sanoj lawrence Apr 13 '15 at 06:34
2 Answers
1
You could use a MERGE statement. It is easy to understand.
MERGE INTO temp_test t
USING temp_test2 u
ON (t.created_by = u.partner_by)
WHEN MATCHED THEN
UPDATE SET
t.country_i = u.country_code
WHERE t.country_i IS NULL
AND u.active = 'A';
Lalit Kumar B
- 45,678
- 12
- 90
- 118
-
@PriankaSingh Thanks for the feedback. Glad that it worked. Please mark it answered. – Lalit Kumar B Apr 13 '15 at 09:24
0
UPDATE temp_test c SET country_i = (select a.country_code from temp_test2 a where a.active = 'A' and c.created_by = a.partner_by) where c.country_i is null;
In my mind it should work...
Dart XKey
- 54
- 3