I need script that read table PRODUCTS and data from this table inesert or update values in the other two tables.
After call function
Read Table PRODUCTS
Read table LIST, if in “list” table have record with same serial as in table PRODUCTS update name with that serial from table products and if don’t have insert id, name and serial with data from products
Read table View, if have record with same name as in table PRODUCTS update description with data from table PRODUCTS or insert id, name, description
If the PRODUCTS table is atomic, and the List and View tables will always match the PRODUCTS table, there is no reason to make copies. Just query the columns you need (when you use them wherever else), instead of “SELECT *”.
If you’re copying them to change them later, or for whatever reason you want to copy. You can run these queries:
TRUNCATE List; — this will empty the List table
TRUNCATE View; — this will empty the View table
INSERT INTO List ( id, name, serial ) SELECT (id, name, serial ) FROM PRODUCTS;
INSERT INTO View ( id, name, description ) SELECT (id, name, description ) FROM PRODUCTS;
Every time you run those 4 simple queries, it will clear List and View and copy the relevant information from PRODUCTS.