Select with expression "other than" with two conditions

4

I would like to know if there is any way to make a select using a where for a field with a parameter other than < > , with two or more items.

To facilitate following example:

select * from TAB_DESPESAS where cd_item <> '0' order by cd_processo;

For this query I have more than one code for the cd_item field, which in this case would be a sort of list (codes: 0, 2, 20 and 21). Therefore, I would like to bring in this query all other items except the items in the list.

    
asked by anonymous 31.07.2017 / 22:58

2 answers

6

Use NOT IN

select * from TAB_DESPESAS where cd_item NOT IN ('0','2','20','21') order by cd_processo;
    
31.07.2017 / 23:05
2

You can use the following command:

SELECT * FROM tabela WHERE COD_STATUS NOT IN ('2','10','5')
    
31.07.2017 / 23:04