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)
COBOLforeverAsked:
Who is Participating?
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
update ps_term_tbl  
set  ssr_trmac_last_dt = term_begin_dt
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
update ps_term_tbl  
set  ssr_trmac_last_dt = term_begin_dt where
0
 
COBOLforeverAuthor Commented:
duh - thanks
0
 
sonicefuCommented:
<<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

0
All Courses

From novice to tech pro — start learning today.