Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
goliath_75
Starting Member
1 Post |
Posted - 2013-09-11 : 05:39:26
|
I've got two database tables: product and original_prices. Both tables have a field product_id (key) and price. I want to add a certain percentage to all prices from table original prices, let's say 50%), and store (update) these prices within table product.I've got this, but it fails at the percentage calculation.UPDATE product, original_prices SET product.price *= (1 + original_prices.original_price * 50 /100) WHERE product.product_id=original_prices.product_id It gives me the error:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*= (1 + original_prices.original_price * 50 /100) WHERE product.product_id' at line 1I hope someone can help me out with this. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-09-11 : 06:07:52
|
try posting at dbforums.com or a mysql site. SQLTeam is on Microsoft SQL Server KH[spoiler]Time is always against us[/spoiler] |
|
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2013-09-11 : 08:33:57
|
Syntax is way off:UPDATE a SET a.price = (b.original_price * 1.5) FROM product a INNER JOIN original_prices bWHERE a.product_id=b.product_id - LumbagoMy blog-> http://thefirstsql.com |
|
|
|
|
|