I have a table called products containing a field called price and I simply want to double the price on every product. Could you give me a hand with an SQL statement I can run within PHP myAdmin please.
All you need to do is use the multiplication operator (*) between the two multiplicand columns ( price * quantity ) in a simple SELECT query. You can give this result an alias with the AS keyword; in our example, we gave the multiplication column an alias of total_price .
The SQL multiply ( * ) operator is used to multiply two or more expressions or numbers.
To multiply more than two columns in Excel, you can use the multiplication formulas similar to the ones discussed above, but include several cells or ranges. For example, to multiply values in columns B, C and D, use one of the following formulas: Multiplication operator: =A2*B2*C2. PRODUCT function: =PRODUCT(A2:C2)
update products set price = price * 2;
it's as easy as
UPDATE
products
SET
price = price*2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With