Archive

Archive for August, 2009

Must Have

August 31st, 2009 admin No comments

Must Have
Must Have

What must i enter into a parameter update query to change more than one field?

i am using an update query to change a the discount value of a product. I want it to be able to change the discount of many items at once. i have tried using commas 1, 3, 37
i have tried adding speech marks “1″ And “3″ And “37″

what syntax must i use to change many rows?



I’m assuming this is an SQL question. I think your problem might be because you are using ‘And’ instead of ‘Or’. An ‘And’ select against a single column will return an empty set unless you have a very unusual data structure. Think of it this way, you just asked the database to tell you which products have an id number of 1, 3, AND 37… when all of your products only have one ID and it’s probably a unique value as well.

Here is an example of an update that would effect multiple rows:

Table name: my_products
Update column: discount_value
Conditions: item_id = 1, 3, 37, or >99

update my_products set discount_value = 0.9 where item_id = 1 or item_id = 3 or item_id = 37 or item_id >= 99;

The exact notation will probably vary some depending on what SQL you are running.

Roxette – It Must Have Been Love


Categories: Uncategorized Tags: