简体   繁体   中英

Update multiple tables in one query, in MySQL

I want update my tables from csv. Now data from csv are imported to table "temp_update_stany", but i cant update tables. Query with no errors, but nothing is updated.

Table from CSV is:

produkt|quantity|price|active|czas

Query:

UPDATE lp2_product tabela 
        INNER JOIN lp2_stock_available stany ON (tabela.id_product = stany.id_product)
        INNER JOIN lp2_product_lang lang ON (tabela.id_product = lang.id_product)
        INNER JOIN temp_update_stany csv ON (tabela.id_product = csv.produkt)
    SET
        tabela.active = csv.active,
        tabela.price = csv.price,
        lang.available_now = csv.czas,
        stany.quantity = csv.quantity
    WHERE
        csv.produkt = tabela.id_product 
        OR csv.produkt = lang.id_product 
        OR csv.produkt = stany.id_product

and output from query:

Modified records: 0 (Perform queries took 0.0322 seconds (s)).

but for example "lp2_product" /row 'active' have value 0 for all products and temp_update_stany have value 1 for all.

Yes, this is prestashop and simple script for update quantity and prices.

As per comments above, the UPDATE reports zero rows affected if there is no net change. So if the tables are already updated with the desired values, the UPDATE is a no-op and no rows are "affected."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM