0

This pseudocode (inaccurate SQL) shows what I want to do.

update tableA (colA, colB, colC, colD)
select b.colA, b.colB, c.colC, c.colD
from tableB b 
    left outer join tableC c 
       on b.id = c.id
    inner join tableA a 
       on c.myNum = a.myNum 
    inner join tableD 
        on a.newId = f.newId
where f.imported = 1

How can I do this in a syntactically correct fashion?

2
  • Why do you have to do it in 1 query ? as you can see here msdn.microsoft.com/en-us/library/aa260662%28SQL.80%29.aspx You can't update 2 field for 2 separate table in 1 query (maybe if you try to play with views but still I can't see why). Commented Aug 27, 2010 at 14:33
  • I don't have to, but I am trying to update >100 fields so it would be much faster to update it in one query than in many queries. Commented Aug 27, 2010 at 14:34

2 Answers 2

2

Something like this:

UPDATE TABLE 
SET ...
FROM Table1, Table2 ....
WHERE .....


update tableA 
 Set a.ColA = b.ColA,
     a.Colb = b.ColB,
     a.ColC = c.Colc,
     a.ColD = c.ColD
from tableB b 
 left outer join tableC c 
   on b.id = c.id
 inner join tableA a 
   on c.myNum = a.myNum 
 inner join tableD 
    on a.newId = f.newId
 where f.imported = 1
Sign up to request clarification or add additional context in comments.

Comments

0
SQL> select *from Dewashish84;

E_ID E_NAME        E_EDUCATION
---------- ------------- ---------------

   100 dewa          MCA
   101 Raj           MSCIT
   145 mohan         BA
   103 ram           MTECH
     5 Sohan         BTECH

SQL>

update harshad set E_NAME= decode(E_EDUCATION,'MCA','dewa','MSCIT','Raj','BA','mohan',
     'MTECH','ram');

 5 rows updated.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.