Will Fix
Will Fix

Reputation: 105

Double a value in a column on every row

I need to double the price of all items in a table of a database in access. Here is what the table structure looks like:

sandwich $5.12
apple $1.25

I need it to become:

sandwich $10.24
apple $2.50

How can I accomplish this?

Upvotes: 0

Views: 9271

Answers (2)

duckah
duckah

Reputation: 100

In Access 2010, create and save a query by navigating to Create > Query Design > [Table Name] > Add > Close. Right-click on the query heading and select SQL View to use these solutions.

To use jzd's method, you can use an update query to change the values in your table.

UPDATE Rates SET Rates.Price = Rates.Price*2;

If you want to retain the original price in the table however, a select query might be a better option.

SELECT Rates.Item, Price*2 AS Doubled
FROM Rates;

In both of these solutions, replace "Rates" with your [Table Name]. "Item" is the product name field, "Price" is the product cost field, and "Doubled" is an example of how to attribute a new name to a calculated field. You can always switch back to the Design View to see how these selectors are used to easily build SQL queries.

Upvotes: 0

jzd
jzd

Reputation: 23629

Use an UPDATE statement to set the price = 2 * price.

Upvotes: 3

Related Questions