Update sql with 2 conditions

2

I have a table with the STATUZ column
This column consists of 3 possible values: NEW, VISUALIZED, DISCARDED

I have a function where I need to implement a SQL row that updates my table and changes all the values in the STATUZ column to: DISCARDED

The logic is:

Refresh in: MyTable , the column: statuz - where it has the value NEW for DISCOUNTED, and where it has the value VISUALIZED for DISCARDED. (at once)

The command I'm using but has no effect is:

 UPDATE toyota_base SET statuz = 'DESCARTADO' WHERE statuz = 'NOVO' and statuz = 'VISUALIZADO';

All help is welcome. Thank you.

    
asked by anonymous 15.07.2015 / 23:39

1 answer

4

statuz has only one value, so it no can be both NOVO and VISUALIZADO so the update does not change any registry.

Change AND (conjunction) by OR (disjunction)

UPDATE toyota_base SET
   statuz = 'DESCARTADO'
WHERE statuz = 'NOVO' or statuz = 'VISUALIZADO';

Or use the IN class () that will have the same effect.

UPDATE toyota_base SET
   statuz = 'DESCARTADO'
WHERE statuz IN('NOVO','VISUALIZADO');
    
15.07.2015 / 23:55