Clay Clay - 1 month ago 6
SQL Question

Trying to update my part table within my database with an update statement and a where clause

I am trying to update my part table where

item_class = HW
and I cant get it right. Can anyone see what is wrong with my syntax.

update part
set unit_price = unit_price + 1.05
where item_class = ' HW ' ;


It provides no error, but it doesn't update the correct rows. It say it is going to update 0 rows when in fact needs to update 4 rows.

Answer

Could you have wrong space try using

update part
set unit_price = unit_price + 1.05
where item_class like  '*HW*' ;

or

update part
set unit_price = unit_price + 1.05
where item_class like  '* HW *' ;

or

update part
set unit_price = unit_price + 1.05
where item_class = 'HW' ;