I have a Prestashop website where I need to increase price for each products and specifically in table “products” I need to multiply column “price” (for each rows that contain already values) for 1.22 (I need to add Italian VAT on this way).
I think that via SQL is the best way without download a csv file, edit via spreadsheet and than re-import.
Someone can show me which SQL command I should use?
Thanks a lot!
6
I believe you could use something as simple as
UPDATE YourTable SET price = price * 1.22
or
UPDATE YourTable SET price = price * YourField
if you have a field with the price value
1
You can use the following SQL code to update the prices:
If you want to update the existing price by applying the 22% Italian VAT:
UPDATE products SET price = price * 1.22
WHERE price > 0;
Alternatively, if you want to keep the original price and add a new column to store the price with Italian VAT:
ALTER TABLE products ADD COLUMN price_with_Italian_VAT DECIMAL(10, 2) AFTER price;
UPDATE products SET price_with_Italian_VAT = price * 1.22
WHERE price > 0;
Here are some additional important notes:
- Check Table Prefix and Column Names: Ensure that you use the correct
table prefix and column names in the queries. - Data Backup: Always back up your database before performing updates.
This ensures you can recover the original values if needed. - Decimal Precision: The DECIMAL(10, 2) data type is commonly used for
monetary values to ensure that prices are stored with two decimal
places. Double-check that the price_with_Italian_VAT column is
defined with the appropriate data type.
Wilbert Koo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
3