Link to home
Start Free TrialLog in
Avatar of COBOLforever
COBOLforeverFlag for United States of America

asked on

SQL Update - very simple

just can't remember - - need to update a a field on every row to another field on the same row - - all records; table has 3 keys - - something like this:
update ps_term_tbl a set a.ssr_trmac_last_dt = a.term_begin_dt where
(select a.institution, a.acad_career, a.strm, a.term_begin_dt, a.ssr_trmac_last_dt,
  b.institution, b.acad_career, b.strm from ps_term_tbl a, ps_term_tbl b where
   a.institution = b.institution and a.acad_career = b.acad_career and a.strm = b.strm)
Avatar of Aneesh
Aneesh
Flag of Canada image

update ps_term_tbl  
set  ssr_trmac_last_dt = term_begin_dt where
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of COBOLforever

ASKER

duh - thanks
<<need to update a a field on every row to another field on the same row - - all records;>>
UPDATE ps_term_tbl a
   SET a.ssr_trmac_last_dt = a.term_begin_dt;
/*
 WHERE (SELECT a.institution, a.acad_career, a.strm, a.term_begin_dt,
               a.ssr_trmac_last_dt, b.institution, b.acad_career, b.strm
          FROM ps_term_tbl a, ps_term_tbl b
         WHERE a.institution = b.institution
           AND a.acad_career = b.acad_career
           AND a.strm = b.strm)
*/

Your update statement is right, only you are using WHERE clause extra
UPDATE ps_term_tbl a
   SET a.ssr_trmac_last_dt = a.term_begin_dt;

Open in new window