Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql multiplication query

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.

like image 945
Mark Avatar asked Apr 04 '12 16:04

Mark


People also ask

How do you do multiplication in MySQL?

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 .

How do you write a multiplication query in SQL?

The SQL multiply ( * ) operator is used to multiply two or more expressions or numbers.

How do you multiply columns?

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)


2 Answers

update products set price = price * 2;
like image 98
Annabel Avatar answered Oct 14 '22 08:10

Annabel


it's as easy as

UPDATE
  products
SET
  price = price*2;
like image 35
oezi Avatar answered Oct 14 '22 10:10

oezi