I have a SQLite database, which needs to be updated. Using the update statement this should be easy.
But things aren't going as planned:
This is the complete query:
UPDATE products_new SET name =
(
SELECT products_sap.title
FROM products_sap, products_new
WHERE products_sap.id_a = products_new.product_id
);
As part of my debugging scheme I'm trying out each (sub)query.
This query ( identical to the one used in the above update ) shows me the correct records:
SELECT products_sap.id, products_sap.title
FROM products_sap, products_new
WHERE products_sap.id_a = products_new.product_id;
Example:
id | title
----------------------
1 | Lorum Ipsum
2 | Lorum Not Ipsum
3 | Ipsum Lorum
But: all my rows in the updated table have identical name
values * gasps *.
SELECT products_new.name from products_new;
Example:
id | name
----------------------
1 | Lorum Ipsum
2 | Lorum Ipsum
3 | Lorum Ipsum
So my question is:
how can I updated each row with it's relevant name
value?