COBOLforever
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)
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)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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;
/*
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;
set ssr_trmac_last_dt = term_begin_dt where