"cybermalandro cybermalandro" <[EMAIL PROTECTED]> wrote on 
03/20/2006 11:00:51 AM:

> I am trying to update a table with a file that has more than one update
> statements like this:
> 
> 
> UPDATE  products set products_price="22.00" WHERE 
products_model="5217-01"
> OR products_model="521701" AND products_um="CS";
> UPDATE  products set products_price="3" WHERE products_model="5217-01" 
OR
> products_model="521701" AND products_um="PK";
> UPDATE  products set products_price="0.25" WHERE 
products_model="5217-01" OR
> products_model="521701" AND products_um="EA";
> 
> In the products table the only record that exist with
> product_model="5217-01" has a products_um="CS" not "EA" but when my 
which
> contains the update statements is executed the last statement is the one
> that actually makes the change therefore resulting in the record to be
> products_price=0.25 instead of 22.  Any ideas why this is happening?
> Shouldn't this statements just match the record and make the update? is
> there another way to do this?
> 
> Thanks!


It has to do with the expression you are using to pick which row to update

WHERE products_model="5217-01" OR products_model="521701" AND 
products_um="CS"

This is parsed as

WHERE products_model="5217-01" OR (products_model="521701" AND 
products_um="CS")

But what I think you wanted to say was

WHERE (products_model="5217-01" OR products_model="521701") AND 
products_um="CS"

Add the parentheses around your OR terms and you should only be changing 
what you wanted to change.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to