sqlite - Update records based on other records in the same table -
i have table (pump_table) pump flow (pump_flow), pump station names (name) , sub name (sub_name) information, presented in table extract below:

i transfer pump_flow value sub_name pump 1 pump_flow field sub_name; pump 2, pump 3,... pump n, of pump station having same name.
the script i've created looks this:
update [pump_table] set [pump_flow] = ( select [pump_flow] [pump_table] [name] = [name] , [sub_name] = "pump 1" ) [name] = [name] , [sub_name] != "pump 1" ; it keeps on returning value pump_flow field of first record in table has 'pump 1' in sub_name field.
the filter name = name matches.
to refer value in table, must use table name. if other table instance of same table, must rename 1 table:
update pump_table set pump_flow = (select pump_flow pump_table p1 p1.name = pump_flow.name , sub_name = 'pump 1') sub_name != 'pump 1';
Comments
Post a Comment