mysql - update a table from the same table. Relation between records in another table -
i have table records called garanzie_row
:
id_cred id_gar cd000001440 cd000001068
cd000001440 , cd000001068 defined in table , each of them has status. table named crediti
id_cre status cd000001440 open cd000001068
what i'd iterate records in records in first table , set in second table status each cred b status of corresponding cred a
but can't find single query select , update in 1 piece (obviously in steps works easily)
if understand correctly, can update
, join
s:
update crediti cb join garanzie_row gr on cb.cred = gr.credb join crediti ca on ca.cred = gr.creda set cb.status = ca.status;
Comments
Post a Comment