Marius Balčytis
You need to run SQL migration script
id | price | status |
---|---|---|
1 | 10.00 | active |
2 | 12.00 | inactive |
3 | 24.00 | inactive |
4 | 43.00 | active |
5 | 51.00 | inactive |
Double the price and activate inactive products
UPDATE prices
SET price = price * 2, status = 'active'
WHERE status = 'inactive';
UPDATE prices SET price = price * 2, status = 'active' WHERE id = 2;
UPDATE prices SET price = price * 2, status = 'active' WHERE id = 3;
UPDATE prices SET price = price * 2, status = 'active' WHERE id = 5;
SELECT *, price * 2 FROM prices WHERE status = 'inactive';
SELECT CONCAT(
'UPDATE prices SET price = ',
price * 2,
', status = "active" WHERE id = ', id,
';'
)
FROM prices WHERE status = 'inactive';
SELECT CONCAT(
'UPDATE prices SET price = ',
price * 2,
', status = "active" WHERE id = ', id,
' AND status = "inactive" AND price = ', price,
';'
)
FROM prices WHERE status = 'inactive';
id | price | status |
---|---|---|
1 | 10.00 | active |
2 | 12.00 | inactive |
3 | 24.00 | inactive |
4 | 43.00 | active |
5 | 51.00 | inactive |
UPDATE prices SET price = 24.00, status = "active" WHERE id = 2 AND status = "inactive" AND price = 12.00;
UPDATE prices SET price = 48.00, status = "active" WHERE id = 3 AND status = "inactive" AND price = 24.00;
UPDATE prices SET price = 102.00, status = "active" WHERE id = 5 AND status = "inactive" AND price = 51.00;