Friday, June 26, 2015

Removing VAT from prices via MySQL

Just a wee note, if you've got prices in a table, for an online shop perhaps, that are Gross, but you want to change them to Net.  So, for example, prices with 20% VAT, switched to an Ex VAT price, you can do this with a neat one line of SQL.



So, via MySQL, perhaps phpMyAdmin, you would do something like...

UPDATE product_table SET price_field = price_field / 1.2


For a practical example, in OpenCart, this would be...

UPDATE oc_product SET price = price / 1.2