sam shah
asked on
sql query
hi experts,
how can i fetch data from two columns present in two different table and update a third table's two columns with that data???
Thanks.
how can i fetch data from two columns present in two different table and update a third table's two columns with that data???
Thanks.
you need to tell us what's the column(s) to be linked with these first 2 tables.
In a very generic way:
UPDATE Table1
SET ColumnName = (SELECT Table2.ColumnName
FROM Table2
INNER JOIN Table3 ON Table2.ID = Table3.ID)
If you give us more information we can give you a more precise answer.
ASKER
MERGE INTO table1 a
USING table2 b
ON (b.col2 = a.col1)
WHEN MATCHED THEN
UPDATE
SET a.col3 = b.col4
"how can i use cursor for this instead of merge'??
USING table2 b
ON (b.col2 = a.col1)
WHEN MATCHED THEN
UPDATE
SET a.col3 = b.col4
"how can i use cursor for this instead of merge'??
Do not use cursor they are costly.. Query will suffice your problem.
So where's the 3rd table in your example?
Also, MERGE means UPDATE when exists and INSERT when not.
This is different from your main question.
Please confirm what you really want.
Also, MERGE means UPDATE when exists and INSERT when not.
This is different from your main question.
Please confirm what you really want.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sam, is your issue solved?
If it is please close this question by accepting one or more comments as solution.
If it is not solved please tell us what's missing so we can help you further.
If it is please close this question by accepting one or more comments as solution.
If it is not solved please tell us what's missing so we can help you further.